简体   繁体   English

go.mod:强制使用特定版本进行间接依赖

[英]go.mod: force use specific version for indirect dependency

Say my direct dependency A depends on package B v1.0 .说我的直接依赖A取决于 package B v1.0 B v1.0 is not listed in go.mod but its checksum exists in go.sum B v1.0未在go.mod中列出,但其校验和存在于go.sum

Is there a way to force my project to use B v1.1 ?有没有办法强制我的项目使用B v1.1 What if package B is a few levels down in the dependency graph?如果 package B在依赖图中低了几级怎么办?

Thanks in advance.提前致谢。

As mentioned in comment, go.mod can have indirect dependencies as following:如评论中所述, go.mod 可以具有以下间接依赖关系:

module test

go 1.16

require (
    github.com/gorilla/mux v1.8.0
    github.com/kr/pretty v0.1.0 // indirect
    golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d // indirect
)

The above is a go.mod from one of my projects.以上是我的一个项目中的 go.mod。 Mind that the // indirect is not a manual comment.请注意// indirect不是手动注释。

To lock a dependency version, just update go.mod or simply do a go get B@1.1要锁定依赖版本,只需更新 go.mod 或简单地执行go get B@1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM