40
40
flagLibFuzzer = flag .Bool ("libfuzzer" , false , "output static archive for use with libFuzzer" )
41
41
flagBuildX = flag .Bool ("x" , false , "print the commands if build fails" )
42
42
flagPreserve = flag .String ("preserve" , "" , "a comma-separated list of import paths not to instrument" )
43
+ flagGoCmd = flag .String ("go" , "go" , `path to "go" command` )
43
44
)
44
45
45
46
func makeTags () string {
@@ -229,7 +230,7 @@ func (c *Context) getEnv() {
229
230
continue
230
231
}
231
232
// TODO: make a single call ("go env GOROOT GOPATH") instead
232
- out , err := exec .Command ("go" , "env" , k ).CombinedOutput ()
233
+ out , err := exec .Command (* flagGoCmd , "env" , k ).CombinedOutput ()
233
234
if err != nil || len (out ) == 0 {
234
235
c .failf ("%s is not set and failed to locate it: 'go env %s' returned '%s' (%v)" , k , k , out , err )
235
236
}
@@ -238,7 +239,7 @@ func (c *Context) getEnv() {
238
239
c .GOROOT = env ["GOROOT" ]
239
240
c .GOPATH = env ["GOPATH" ]
240
241
241
- out , err := exec .Command ("go" , "list" , "-f" , "'{{context.ReleaseTags}}'" , "runtime" ).CombinedOutput ()
242
+ out , err := exec .Command (* flagGoCmd , "list" , "-f" , "'{{context.ReleaseTags}}'" , "runtime" ).CombinedOutput ()
242
243
if err != nil || len (out ) == 0 {
243
244
c .failf ("go list -f '{{context.ReleaseTags}}' runtime returned '%s' (%v)" , out , err )
244
245
}
@@ -526,7 +527,7 @@ func (c *Context) buildInstrumentedBinary(blocks *[]CoverBlock, sonar *[]CoverBl
526
527
args = append (args , "-trimpath" )
527
528
}
528
529
args = append (args , "-o" , outf , mainPkg )
529
- cmd := exec .Command ("go" , args ... )
530
+ cmd := exec .Command (* flagGoCmd , args ... )
530
531
531
532
// We are constructing a GOPATH environment, so while building
532
533
// we force GOPATH mode here via GO111MODULE=off.
0 commit comments