Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: reject vendor directories as module-mode build arguments unless -mod=vendor is set #32921

bcmills opened this issue Jul 3, 2019 · 0 comments


Copy link

@bcmills bcmills commented Jul 3, 2019

There is a TODO here yet to be done:

if strings.HasPrefix(suffix, "/vendor/") {
// TODO getmode vendor check
pkg = strings.TrimPrefix(suffix, "/vendor/")

The effect of the missing check is that when -mod=vendor is not set, running go build or go test with an empty directory path beginning with ./vendor causes the go command to resolve and download the corresponding module, ignoring the contents of the vendor directory.$ go1.13beta1 mod init
go: creating new go.mod: module$ go1.13beta1 build ./vendor/
can't load package: package unknown import path "": cannot find package$ mkdir -p vendor/$ go1.13beta1 build ./vendor/
go: finding v0.3.2
go: downloading v0.3.2
go: extracting v0.3.2$

(Found while investigating #32917.)

@bcmills bcmills added this to the Go1.14 milestone Jul 3, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.