当前位置:网站首页>When golang operates mongodb, vscode prompts primitive E composite literal uses unlocked fields
When golang operates mongodb, vscode prompts primitive E composite literal uses unlocked fields
2022-06-22 09:34:00 【ootw】
cannot use "category_title" (untyped string constant) as primitive.E value in array or slice literal (compile)go-staticcheck
According to my current experience , When using bson.D This prompt will appear when . Although it does not affect operation , But it's always uncomfortable . Using Baidu Dafa, I found only one paragraph of English information , I tried to understand the general meaning by looking up the dictionary , The writing is not standard .
filter := bson.D{
{"category_title", " Online total "}}Like the above paragraph , Need to add key and value Change to the following :
filter := bson.D{primitive.E{Key:"category_title", Value:" Online total "}}It can also be simplified a little , Don't primitive.E:
filter := bson.D{
{Key:"category_title", Value:" Online total "}}
It's ok .
If the sequence is not required , It can be used bson.M, It's simpler , like this :
filter := bson.M{"category_title": " Online total "}Actually, I'm a beginner , If there is anything wrong , Please tell me , Common progress , Thank you !
Original address of English materials :
https://stackoverflow.com/questions/54548441/composite-literal-uses-unkeyed-fields
边栏推荐
- Find the size of cosine
- C language brush question | temperature conversion (11)
- copy_ from_ User and copy_ to_ user
- Double machine hot standby of firewall on ENSP
- 5 interview questions, grasp the underlying principle of string!
- C语言刷题 | 判断某年是否只闰年(15)
- Audio and video 2022 beauty function introduction teach you to play video beauty
- Payment order case construction
- Recruitment order | data visualization development platform "flyfish" super experience Officer Recruitment
- 6-44 traversal of binary tree
猜你喜欢

Lifecycle of Servlet

论文笔记:DETR: End-to-End Object Detection with Transformers (from 李沐老师and朱老师)

Mapping multiple exit servers on ENSP

Win+sublime Text3 + go 1.9.2 environment setup diagram

day367:有效的完全平方数

Audio and video 2022 beauty function introduction teach you to play video beauty

架设多个web站点

Fuzzy query and aggregate function

Lexical Sign Sequence

Volumedetect of ffmpeg
随机推荐
两个线程各执行100次i++,得到的可能值
FileZilla server prompts 550 could not open file for reading when downloading files (illustration)
在ensp上做防火墙的双机热备
Apprentissage automatique | nltk Erreur de téléchargement des données | solution d'erreur de téléchargement du corpus stopwords pour nltk
機器學習|nltk_Data下載錯誤|nltk的stopwords語料下載錯誤解决方法
Opencv daily function histogram correlation (3)
模糊查询和聚合函数
函数总结(1)
Stream流创建_操作_收集_案例
Jinglianwen Technology: product summary of machine learning AI dataset (III)
DHCP Relay
There are three ways to traverse the map. Second, you know
[学习笔记] 回滚莫队
VMware installation Kali
MySQL中常用的SQL语句
day500:键盘行
pytorch的模块使用:线性模型(未完成)
论文笔记:DETR: End-to-End Object Detection with Transformers (from 李沐老师and朱老师)
C语言刷题 | 输入一个数输出对应的值(13)
simple_strtoull字符转换相关函数