support Go versions with X: suffixes for GOEXPERIMENTs

A workaround until https://github.com/golang/go/issues/75953 is fixed.

See #978.
This commit is contained in:
Daniel Martí
2025-10-17 23:25:26 +01:00
committed by Paul Scheduikat
parent 15a385283b
commit 37e582d581
2 changed files with 10 additions and 1 deletions

View File

@@ -731,6 +731,9 @@ To install Go, see: https://go.dev/doc/install
if err := json.Unmarshal(out, &sharedCache.GoEnv); err != nil {
return fmt.Errorf(`cannot unmarshal from "go env -json": %w`, err)
}
// TODO: remove once https://github.com/golang/go/issues/75953 is fixed,
// such that `go env GOVERSION` can always be parsed by go/version.
sharedCache.GoEnv.GOVERSION, _, _ = strings.Cut(sharedCache.GoEnv.GOVERSION, " ")
// Some Go version managers switch between Go versions via a GOROOT which symlinks
// to one of the available versions. Given that later we build a patched linker

View File

@@ -12,7 +12,7 @@ stderr 'Go version is too old; please upgrade to go1\.25\.0 or newer'
# A clearly invalid go version.
env TOOLCHAIN_GOVERSION='bogus version'
! exec garble build
stderr 'Go version "bogus version" appears to be invalid or too old; use go1\.25\.0 or newer'
stderr 'Go version "bogus" appears to be invalid or too old; use go1\.25\.0 or newer'
# We should error on a devel version that's too old;
# note that they started with the string "devel",
@@ -49,6 +49,12 @@ env TOOLCHAIN_GOVERSION='go1.25.0-somecustomversion'
! exec garble build
stderr 'mocking the real build'
# A stable version with a build-time GOEXPERIMENT.
# See: https://github.com/golang/go/issues/75953
env TOOLCHAIN_GOVERSION='go1.25.0 X:nodwarf5'
! exec garble build
stderr 'mocking the real build'
# The current toolchain may be older than the one that built garble.
env GARBLE_TEST_GOVERSION='go1.25.1'
env TOOLCHAIN_GOVERSION='go1.25.0'