]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet/all: don't use the x/tools vet in GOPATH
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 25 Mar 2019 22:57:27 +0000 (22:57 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Mar 2019 16:29:00 +0000 (16:29 +0000)
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: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/vet/all/main.go

index 6e4a4e297eb89088ed137c75ebdce3d6821513da..e4f8eccd8c37d69c27f7bc9c071eeb0daa410026 100644 (file)
@@ -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 {