Mozhi
Mozhi

Reputation: 827

How to use go list -u -m all with vendoring mode?

I just upgraded to go1.14 and running go list -u -m all command with -mod=vendor GOFLAG , i encountered can't determine available upgrades using the vendor directory. I went through the release notes (https://golang.org/doc/go1.14#go-command) but couldn't figure out why this error. ( My go.mod and vendor/modules.txt were in sync ).

When to use -mod=readonly like go list -mod=readonly -u -m all command? What's wrong with using go list -u -m all with -mod=vendor?

Any pointers would be much appreciated . Thank you.

GOGOPATH=/home/vagrant/go_workspace
GO111MODULE=on
GOFLAGS=-mod=vendor
============================================
go list  -u -m all
go list -m: can't determine available upgrades using the vendor directory
        (Use -mod=mod or -mod=readonly to bypass.)

Upvotes: 3

Views: 3376

Answers (1)

bcmills
bcmills

Reputation: 5197

-mod=vendor requests that the go command resolve information about your dependencies using only the information in the vendor directory.

The vendor directory necessarily does not contain information about available upgrades, because the vendor directory itself is created at a single point in time. In order to determine available upgrades, you must make a network connection to either a module proxy server or the origin server to see what other versions have become available.

So the two flags really are incompatible: either you can check for upgrades, or you can use only what's in the vendor directory, but not both at once.

Upvotes: 5

Related Questions