Skip to content

Commit 96a6dd7

Browse files
committed
Go: Move go version command construction into its own function
1 parent be027e2 commit 96a6dd7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

go/extractor/toolchain/toolchain.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func GetEnvGoVersion() string {
2525
// download the version of Go specified in there. That may either fail or result in us just
2626
// being told what's already in 'go.mod'. Setting 'GOTOOLCHAIN' to 'local' will force it
2727
// to use the local Go toolchain instead.
28-
cmd := exec.Command("go", "version")
28+
cmd := Version()
2929
cmd.Env = append(os.Environ(), "GOTOOLCHAIN=local")
3030
out, err := cmd.CombinedOutput()
3131

@@ -92,3 +92,9 @@ func VendorModule(path string) *exec.Cmd {
9292
modVendor.Dir = path
9393
return modVendor
9494
}
95+
96+
// Constructs a command to run `go version`.
97+
func Version() *exec.Cmd {
98+
version := exec.Command("go", "version")
99+
return version
100+
}

0 commit comments

Comments
 (0)