@@ -23,7 +23,7 @@ var goVersions = map[string]struct{}{}
2323
2424// Adds an entry to the set of installed Go versions for the normalised `version` number.
2525func addGoVersion (version string ) {
26- goVersions [semver .Canonical (version )] = struct {}{}
26+ goVersions [semver .Canonical ("v" + version )] = struct {}{}
2727}
2828
2929// Returns the current Go version as returned by 'go version', e.g. go1.14.4
@@ -42,14 +42,14 @@ func GetEnvGoVersion() string {
4242 }
4343
4444 goVersion = parseGoVersion (string (out ))
45- addGoVersion (goVersion )
45+ addGoVersion (goVersion [ 2 :] )
4646 }
4747 return goVersion
4848}
4949
5050// Determines whether, to our knowledge, `version` is available on the current system.
5151func HasGoVersion (version string ) bool {
52- _ , found := goVersions [semver .Canonical (version )]
52+ _ , found := goVersions [semver .Canonical ("v" + version )]
5353 return found
5454}
5555
@@ -63,7 +63,7 @@ func InstallVersion(workingDir string, version string) bool {
6363 // Construct a command to invoke `go version` with `GOTOOLCHAIN=go1.N.0` to give
6464 // Go a valid toolchain version to download the toolchain we need; subsequent commands
6565 // should then work even with an invalid version that's still in `go.mod`
66- toolchainArg := "GOTOOLCHAIN=go" + semver .Canonical (version )
66+ toolchainArg := "GOTOOLCHAIN=go" + semver .Canonical ("v" + version )[ 1 :]
6767 versionCmd := Version ()
6868 versionCmd .Dir = workingDir
6969 versionCmd .Env = append (os .Environ (), toolchainArg )
0 commit comments