简体   繁体   中英

go.mod: force use specific version for indirect dependency

Say my direct dependency A depends on package B v1.0 . B v1.0 is not listed in go.mod but its checksum exists in go.sum

Is there a way to force my project to use B v1.1 ? What if package B is a few levels down in the dependency graph?

Thanks in advance.

As mentioned in comment, go.mod can have indirect dependencies as following:

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. Mind that the // indirect is not a manual comment.

To lock a dependency version, just update go.mod or simply do a go get B@1.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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