Commit db7e7469 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

cmd/vet/all: don't use the x/tools vet in GOPATH

Updates golang/go#31040

Change-Id: I76e3044b2cc992e63194654a825e70307075eff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169237
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDmitri Shuralyov <dmitshur@golang.org>
parent cd530935
......@@ -243,7 +243,17 @@ func (p platform) vet() {
}
cmd := exec.Command(cmdGoPath, "build", "-o", vetTool, "golang.org/x/tools/go/analysis/cmd/vet")
cmd.Env = os.Environ()
cmd.Env = append(os.Environ(),
// Setting GO111MODULE to on is redundant in master
// (Go 1.13), but not if we backport this to Go 1.11/1.12
// release branches (for our own builder usage) or if
// master ends up reverting its GO111MODULE default. If
// that happens, we want to force it on here anyway, as
// we're now depending on it.
"GO111MODULE=on",
)
// Use the module that cmd/vet/all is a part of:
cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "cmd", "vet", "all")
// golang.org/x/tools does not have a vendor directory, so don't try to use
// one in module mode.
......@@ -259,19 +269,6 @@ func (p platform) vet() {
}
}
// The coordinator places a copy of golang.org/x/tools in GOPATH.
// If we can find it there, use that specific version.
for _, gp := range filepath.SplitList(os.Getenv("GOPATH")) {
gopathDir := filepath.Join(gp, "src", "golang.org", "x", "tools", "go", "analysis", "cmd", "vet")
if _, err := os.Stat(gopathDir); err == nil {
cmd.Dir = gopathDir
}
}
if cmd.Dir == "" {
// Otherwise, move to tmpdir and let the module loader resolve the latest version.
cmd.Dir = tmpdir
}
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stderr
if err := cmd.Run(); err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment