Skip to content

Commit 6912566

Browse files
cuonglmjosharian
authored andcommitted
go-fuzz-build: allow specify go binary path
1 parent 6a8e9d1 commit 6912566

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: go-fuzz-build/main.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var (
4040
flagLibFuzzer = flag.Bool("libfuzzer", false, "output static archive for use with libFuzzer")
4141
flagBuildX = flag.Bool("x", false, "print the commands if build fails")
4242
flagPreserve = flag.String("preserve", "", "a comma-separated list of import paths not to instrument")
43+
flagGoCmd = flag.String("go", "go", `path to "go" command`)
4344
)
4445

4546
func makeTags() string {
@@ -229,7 +230,7 @@ func (c *Context) getEnv() {
229230
continue
230231
}
231232
// 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()
233234
if err != nil || len(out) == 0 {
234235
c.failf("%s is not set and failed to locate it: 'go env %s' returned '%s' (%v)", k, k, out, err)
235236
}
@@ -238,7 +239,7 @@ func (c *Context) getEnv() {
238239
c.GOROOT = env["GOROOT"]
239240
c.GOPATH = env["GOPATH"]
240241

241-
out, err := exec.Command("go", "list", "-f", "'{{context.ReleaseTags}}'", "runtime").CombinedOutput()
242+
out, err := exec.Command(*flagGoCmd, "list", "-f", "'{{context.ReleaseTags}}'", "runtime").CombinedOutput()
242243
if err != nil || len(out) == 0 {
243244
c.failf("go list -f '{{context.ReleaseTags}}' runtime returned '%s' (%v)", out, err)
244245
}
@@ -526,7 +527,7 @@ func (c *Context) buildInstrumentedBinary(blocks *[]CoverBlock, sonar *[]CoverBl
526527
args = append(args, "-trimpath")
527528
}
528529
args = append(args, "-o", outf, mainPkg)
529-
cmd := exec.Command("go", args...)
530+
cmd := exec.Command(*flagGoCmd, args...)
530531

531532
// We are constructing a GOPATH environment, so while building
532533
// we force GOPATH mode here via GO111MODULE=off.

0 commit comments

Comments
 (0)