dttphb59319 2018-12-17 13:49
浏览 212

无法将(包含指针的结构)类型转换为* bsonx.Document

I've recently started using the official mongo-go-driver (github.com/mongodb/mongo-go-driver) and it seems that I cannot use pointers in my structs -> ex.:

type example struct {
  hello *string
}

If you initialize this struct and try to insert it to the database, you get the error:

"Failed to insert doc: cannot transform type example to a *bsonx.Document"

Diving deeper into the library, I find this error:

"StringEncodeValue can only process string, but got a *string"

Does this mean that pointers can not be used at all? If so, does anyone know why pointers would not be supported?

Using a different type produces the same result. Example error when using an integer type:

"IntEncodeValue can only process int8, int16, int32, int64, int, but got a *int"
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求TYPCE母转母转接头24PIN线路板图
    • ¥100 国外网络搭建,有偿交流
    • ¥15 高价求中通快递查询接口
    • ¥15 解决一个加好友限制问题 或者有好的方案
    • ¥15 急matlab编程仿真二阶震荡系统
    • ¥20 TEC-9的数据通路实验
    • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
    • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型