登录
首页 >  Golang >  Go问答

无法安装最新版本的 mongo-go-driver (v1.2.1)

来源:stackoverflow

时间:2024-04-11 20:45:31 486浏览 收藏

欢迎各位小伙伴来到golang学习网,相聚于此都是缘哈哈哈!今天我给大家带来《无法安装最新版本的 mongo-go-driver (v1.2.1)》,这篇文章主要讲到等等知识,如果你对Golang相关的知识非常感兴趣或者正在自学,都可以关注我,我会持续更新相关文章!当然,有什么建议也欢迎在评论留言提出!一起学习!

问题内容

我无法获取 mongo-go-driver v1.2.1。我正在使用 dep 来解决依赖性。 我的导入块看起来像 -

import (
  "go.mongodb.org/mongo-driver/mongo"
  "go.mongodb.org/mongo-driver/mongo/options"
  "go.mongodb.org/mongo-driver/bson"

  "fmt"
  "context"
)

当我运行 dep ensure -v 时,我得到以下输出

(50)  ✗   github.com/mongodb/mongo-go-driver at v1.2.1 has problem subpkg(s):
(50)        github.com/mongodb/mongo-go-driver/bson/objectid is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/private/cluster is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/readpref has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/writeconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/bson has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].  github.com/mongodb/mongo-go-driver/bson/decimal is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/bson/elements is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/connstring is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/options has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/private/ops is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/readconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].
(49)      try github.com/mongodb/[email protected]
(50)  ✗   github.com/mongodb/mongo-go-driver at v1.2.0 has problem subpkg(s):
(50)        github.com/mongodb/mongo-go-driver/bson/objectid is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/options has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/readconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/bson/elements is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/bson/decimal is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/connstring is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/private/cluster is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/private/ops is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/readpref has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/writeconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/bson has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].
(49)      try github.com/mongodb/[email protected]
(50)  ✗   github.com/mongodb/mongo-go-driver at v1.1.4 has problem subpkg(s):
(50)        github.com/mongodb/mongo-go-driver/mongo/private/cluster is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/private/ops is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/readconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/mongo/readpref has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/writeconcern has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/connstring is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/bson/decimal is missing; required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/bson/elements is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/bson/objectid is missing; required by go.mongodb.org/[email protected].    github.com/mongodb/mongo-go-driver/mongo/options has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected]. github.com/mongodb/mongo-go-driver/bson has err (*pkgtree.NonCanonicalImportRoot); required by go.mongodb.org/[email protected].

.
.
.


(49)      try github.com/mongodb/[email protected]
(50)  ✗   github.com/mongodb/mongo-go-driver at v0.0.2 has problem subpkg(s):
(50)        github.com/mongodb/mongo-go-driver/mongo/options is missing; required by go.mongodb.org/[email protected].
(49)      try github.com/mongodb/[email protected]
(49)  ✓ select github.com/mongodb/[email protected] w/20 pkgs

最后它导入了 v.0.0.1。请帮忙。


解决方案


我已经解决了这个问题。这是其他面临该问题的人的解决方案。 将以下行添加到 gopkg.toml

[[constraint]]
  name = "go.mongodb.org/mongo-driver"
  version = "~1.2.0"

您可以将版本值替换为您所需的版本。

今天关于《无法安装最新版本的 mongo-go-driver (v1.2.1)》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>