Go: Move go version command construction into its own function

This commit is contained in:
Michael B. Gale
2024-03-20 13:08:59 +00:00
parent be027e217e
commit 96a6dd72cd

View File

@@ -25,7 +25,7 @@ func GetEnvGoVersion() string {
// download the version of Go specified in there. That may either fail or result in us just
// being told what's already in 'go.mod'. Setting 'GOTOOLCHAIN' to 'local' will force it
// to use the local Go toolchain instead.
cmd := exec.Command("go", "version")
cmd := Version()
cmd.Env = append(os.Environ(), "GOTOOLCHAIN=local")
out, err := cmd.CombinedOutput()
@@ -92,3 +92,9 @@ func VendorModule(path string) *exec.Cmd {
modVendor.Dir = path
return modVendor
}
// Constructs a command to run `go version`.
func Version() *exec.Cmd {
version := exec.Command("go", "version")
return version
}