Golang MongoDB导入问题

导入golang mongodb驱动程序时遇到的问题。 </ p>

  go get -u go.mongodb.org/mongo-driver/mongo
go get -u go.mongodb.org/mongo-driver/mongo@~1.0。 0
</ code> </ pre>

包go.mongodb.org/mongo-driver/mongo:无法识别的导入路径“ go.mongodb.org/mongo-driver/mongo” (https提取:获取 https://go.mongodb.org/mongo -driver / mongo?go-get = 1 :拨打tcp:lookup go.mongodb.org:
没有这样的主机)</ strong> </ p>
</ div>

展开原文

原文

Facing issue importing golang mongodb driver.

  go get -u go.mongodb.org/mongo-driver/mongo
  go get -u go.mongodb.org/mongo-driver/mongo@~1.0.0

package go.mongodb.org/mongo-driver/mongo: unrecognized import path "go.mongodb.org/mongo-driver/mongo" (https fetch: Get https://go.mongodb.org/mongo-driver/mongo?go-get=1: dial tcp: lookup go.mongodb.org: no such host)

dqprf0976
dqprf0976 似乎是网络问题,其中DNS无法解析主机名“go.mongodb.org”。您能否通过提供网络环境(在防火墙等后面)来澄清问题?
一年多之前 回复

2个回答



我建议使用mgo库。</ p>

  import(
mgo“ gopkg.in/mgo.v2"
)
</ pre>

您可以在此处找到有关此库的更多信息: https://gopkg.in/mgo.v2 </ p>

我在多个网站上都使用了它,就像一个魅力一样 每次。</ p>
</ div>

展开原文

原文

I would suggest using the mgo library.

import (
    mgo "gopkg.in/mgo.v2"
)

You can find more information about this library here: https://gopkg.in/mgo.v2

I used it for multiple websites and it worked like a charm every time.



这似乎是网络问题。 尝试其他不受防火墙限制的网络连接。 </ p>

否则,您可以使用go mod自动解决依赖关系。</ p>

我还在mongo DB上使用了相同的驱动程序,并且运行良好 。</ p>

请在此处进行检查- Golang-Mongo- 驱动程序示例 </ p>
</ div>

展开原文

原文

It seems to be a network issue. Try some another network connection which is not ruled under firewall.

Or else you can use go mod to resolve dependencies automatically.

I am also using the same driver for mongo DB and it is working perfectly fine.

Kindly check here - Golang-Mongo-Driver-Example

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问