File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,19 @@ var goVersion = ""
6161// Returns the current Go version as returned by 'go version', e.g. go1.14.4
6262func getEnvGoVersion () string {
6363 if goVersion == "" {
64- gover , err := exec .Command ("go" , "version" ).CombinedOutput ()
64+ // Since Go 1.21, running 'go version' in a directory with a 'go.mod' file will attempt to
65+ // download the version of Go specified in there. That may either fail or result in us just
66+ // being told what's already in 'go.mod'. Setting 'GOTOOLCHAIN' to 'local' will force it
67+ // to use the local Go toolchain instead.
68+ cmd := exec .Command ("go" , "version" )
69+ cmd .Env = append (os .Environ (), "GOTOOLCHAIN=local" )
70+ out , err := cmd .CombinedOutput ()
71+
6572 if err != nil {
6673 log .Fatalf ("Unable to run the go command, is it installed?\n Error: %s" , err .Error ())
6774 }
68- goVersion = parseGoVersion (string (gover ))
75+
76+ goVersion = parseGoVersion (string (out ))
6977 }
7078 return goVersion
7179}
You can’t perform that action at this time.
0 commit comments