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

Open
bcmills opened this issue Jul 3, 2019 · 0 comments
Labels
Milestone

Comments

@bcmills
Copy link
Member

@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.

example.com$ go1.13beta1 mod init example.com
go: creating new go.mod: module example.com

example.com$ go1.13beta1 build ./vendor/golang.org/x/text/unicode
can't load package: package golang.org/x/text/unicode: unknown import path "golang.org/x/text/unicode": cannot find package

example.com$ mkdir -p vendor/golang.org/x/text/unicode

example.com$ go1.13beta1 build ./vendor/golang.org/x/text/unicode
go: finding golang.org/x/text v0.3.2
go: downloading golang.org/x/text v0.3.2
go: extracting golang.org/x/text v0.3.2

example.com$

(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
Projects
None yet
2 participants
You can’t perform that action at this time.