1

我最近开始使用官方的 mongo-go-driver (github.com/mongodb/mongo-go-driver),看来我不能在我的结构中使用指针-> 例如:

type example struct {
  hello *string
}

如果初始化此结构并尝试将其插入数据库,则会收到错误消息:

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

深入研究图书馆,我发现了这个错误:

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

这是否意味着指针根本无法使用?如果是这样,有谁知道为什么不支持指针?

使用不同的类型会产生相同的结果。使用整数类型时的示例错误:

"IntEncodeValue can only process int8, int16, int32, int64, int, but got a *int"
4

0 回答 0