@@ -23,7 +23,7 @@ var goVersions = map[string]struct{}{}
23
23
24
24
// Adds an entry to the set of installed Go versions for the normalised `version` number.
25
25
func addGoVersion (version string ) {
26
- goVersions [semver .Canonical (version )] = struct {}{}
26
+ goVersions [semver .Canonical ("v" + version )] = struct {}{}
27
27
}
28
28
29
29
// Returns the current Go version as returned by 'go version', e.g. go1.14.4
@@ -42,14 +42,14 @@ func GetEnvGoVersion() string {
42
42
}
43
43
44
44
goVersion = parseGoVersion (string (out ))
45
- addGoVersion (goVersion )
45
+ addGoVersion (goVersion [ 2 :] )
46
46
}
47
47
return goVersion
48
48
}
49
49
50
50
// Determines whether, to our knowledge, `version` is available on the current system.
51
51
func HasGoVersion (version string ) bool {
52
- _ , found := goVersions [semver .Canonical (version )]
52
+ _ , found := goVersions [semver .Canonical ("v" + version )]
53
53
return found
54
54
}
55
55
@@ -63,7 +63,7 @@ func InstallVersion(workingDir string, version string) bool {
63
63
// Construct a command to invoke `go version` with `GOTOOLCHAIN=go1.N.0` to give
64
64
// Go a valid toolchain version to download the toolchain we need; subsequent commands
65
65
// 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 :]
67
67
versionCmd := Version ()
68
68
versionCmd .Dir = workingDir
69
69
versionCmd .Env = append (os .Environ (), toolchainArg )
0 commit comments