Open vanishcode opened 5 years ago
其实自己crtl+f搜索就可以,链接:
crtl+f
https://github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go
不过不知什么原因,官方的示例
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) client, err := mongo.Connect(ctx, "mongodb://localhost:27017")
我总是失败,后来我试了一下这种
client, err := mongo.Connect(context.Background(), "mongodb://localhost:27017", nil)
就好使了 推测可能是context这里出了什么问题或者自己没用对。。。。。。
其实自己
crtl+f
搜索就可以,链接:https://github.com/mongodb/mongo-go-driver/blob/master/examples/documentation_examples/examples.go
不过不知什么原因,官方的示例
我总是失败,后来我试了一下这种
就好使了 推测可能是context这里出了什么问题或者自己没用对。。。。。。