@@ -243,7 +243,17 @@ func (p platform) vet() {
243
243
}
244
244
245
245
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" )
247
257
248
258
// golang.org/x/tools does not have a vendor directory, so don't try to use
249
259
// one in module mode.
@@ -259,19 +269,6 @@ func (p platform) vet() {
259
269
}
260
270
}
261
271
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
-
275
272
cmd .Stderr = os .Stderr
276
273
cmd .Stdout = os .Stderr
277
274
if err := cmd .Run (); err != nil {
0 commit comments