【发布时间】:2019-08-05 01:47:27
【问题描述】:
我已经尝试了驱动程序 mongodb 进行简单的连接,例如来自这个 repos github mongo-go-driver 的教程我只是这样写客户端:
import (
"fmt"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/mongodb/mongo-go-driver/mongo/options"
)
var client *mongo.Client
func main() {
fmt.Println("Starting the application...")
client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
if err != nil {
fmt.Println(err.Error())
return
}
}
但显示错误:
不能使用 "github.com/mongodb/mongo-go-driver/mongo/options".Client().ApplyURI("mongodb://localhost:27017") (类型 *"github.com/mongodb/mongo -go-driver/mongo/options".ClientOptions) 作为类型 *"go.mongodb.org/mongo-driver/mongo/options".ClientOptions 在 mongo.NewClient 的参数中
驱动版本使用V1.0.0
有什么建议吗?
【问题讨论】: