Skip to content

Commit db7e746

Browse files
committed
cmd/vet/all: don't use the x/tools vet in GOPATH
Updates #31040 Change-Id: I76e3044b2cc992e63194654a825e70307075eff3 Reviewed-on: https://go-review.googlesource.com/c/go/+/169237 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent cd53093 commit db7e746

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/cmd/vet/all/main.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,17 @@ func (p platform) vet() {
243243
}
244244

245245
cmd := exec.Command(cmdGoPath, "build", "-o", vetTool, "golang.org/x/tools/go/analysis/cmd/vet")
246-
cmd.Env = os.Environ()
246+
cmd.Env = append(os.Environ(),
247+
// Setting GO111MODULE to on is redundant in master
248+
// (Go 1.13), but not if we backport this to Go 1.11/1.12
249+
// release branches (for our own builder usage) or if
250+
// master ends up reverting its GO111MODULE default. If
251+
// that happens, we want to force it on here anyway, as
252+
// we're now depending on it.
253+
"GO111MODULE=on",
254+
)
255+
// Use the module that cmd/vet/all is a part of:
256+
cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "cmd", "vet", "all")
247257

248258
// golang.org/x/tools does not have a vendor directory, so don't try to use
249259
// one in module mode.
@@ -259,19 +269,6 @@ func (p platform) vet() {
259269
}
260270
}
261271

262-
// The coordinator places a copy of golang.org/x/tools in GOPATH.
263-
// If we can find it there, use that specific version.
264-
for _, gp := range filepath.SplitList(os.Getenv("GOPATH")) {
265-
gopathDir := filepath.Join(gp, "src", "golang.org", "x", "tools", "go", "analysis", "cmd", "vet")
266-
if _, err := os.Stat(gopathDir); err == nil {
267-
cmd.Dir = gopathDir
268-
}
269-
}
270-
if cmd.Dir == "" {
271-
// Otherwise, move to tmpdir and let the module loader resolve the latest version.
272-
cmd.Dir = tmpdir
273-
}
274-
275272
cmd.Stderr = os.Stderr
276273
cmd.Stdout = os.Stderr
277274
if err := cmd.Run(); err != nil {

0 commit comments

Comments
 (0)