简体   繁体   中英

Go mod use last version, not commit

I want to use library according to last commit not to last release. So I got that version:

$ go get github.com/epsagon/epsagon-go@636ea43

Now in packages cache I have:

$ cd /Users/sgetman/go/pkg/mod/github.com/epsagon && ls

epsagon-go@v1.14.0                  epsagon-go@v1.14.1-0.20201105151128-636ea43d1943

But when I try go build , go test , go mod tidy :

go: finding module for package github.com/epsagon/epsagon-go/epsagon/wrappers/gin
github.com/nexmoinc/neru-runtimelib/router imports
        github.com/epsagon/epsagon-go/epsagon/wrappers/gin: module github.com/epsagon/epsagon-go@latest found (v1.14.0), but does not contain package github.com/epsagon/epsagon-go/epsagon/wrappers/gin

At the same time my go.mod:

require (
    ...
    github.com/epsagon/epsagon-go v1.14.1-0.20201105151128-636ea43d1943
    ...
)

go.sum:

github.com/epsagon/epsagon-go v1.14.0 h1:Tq7qyoyDs2aUCc/UsQEHFt89aXVdUmjWXHwvS5kfSC4=
github.com/epsagon/epsagon-go v1.14.1-0.20201105151128-636ea43d1943 h1:kJGvRsqRfo1h8vEEGajWa+szA9965Epw83Fm3UmmwEc=
github.com/epsagon/epsagon-go v1.14.1-0.20201105151128-636ea43d1943/go.mod h1:Q73D3EhfzqmQa6m6Xi5n0Ugw9l6XSNGCzMcozsFMD1c=

Could you please help me to sort why go mod relys on the latest version, not version I provided?

The go command is checking the latest version because package github.com/nexmoinc/neru-runtimelib/router contains an import statement like import "github.com/epsagon/epsagon-go/epsagon/wrappers/gin" .

github.com/epsagon/epsagon-go v1.14.1-0.20201105151128-636ea43d1943 does not contain such a package, so the go command is trying to figure out whether it can upgrade that module to a newer version in order to find the imported package.

If you run go build -mod=readonly , you will hopefully get a clearer error message. (Note that -mod=readonly will be the default as of Go 1.16: see https://tip.golang.org/doc/go1.16#modules. )

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