如何在mongodb网格fs中导入库?

我正在尝试在MongoDB网格fs上工作,我是新手。我找到了在线资源,使gridfs在golang中工作,我找到了这篇文章。当我获取代码并尝试运行它时,它给了我以下错误。


错误


could not import go.mongodb.org/mongo-driver/mongo/gridfs (cannot find package "go.mongodb.org/mongo-driver/mongo/gridfs" in any of 

/usr/local/go/src/go.mongodb.org/mongo-driver/mongo/gridfs (from $GOROOT)

/home/bilal/go/src/go.mongodb.org/mongo-driver/mongo/gridfs (from $GOPATH))

图书馆


"go.mongodb.org/mongo-driver/bson"

"go.mongodb.org/mongo-driver/mongo"

"go.mongodb.org/mongo-driver/mongo/gridfs"

"go.mongodb.org/mongo-driver/mongo/options"

这四个库给了我这个错误。但我只举了一个错误的例子。


繁星点点滴滴
浏览 53回答 1
1回答

蝴蝶不菲

似乎您尚未正确安装依赖项。首先,您需要按照参考文章中所述设置项目。go mod init PROJECT-NAME然后,您需要安装依赖项,如最初链接的文章中所述:go get go.mongodb.org/mongo-driver/mongo go get go.mongodb.org/mongo-driver/mongo/gridfs
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go