support Go versions with X: suffixes for GOEXPERIMENTs

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

See #978.
master
Daniel Martí 4 months ago committed by Paul Scheduikat
parent 15a385283b
commit 37e582d581

@ -731,6 +731,9 @@ To install Go, see: https://go.dev/doc/install
if err := json.Unmarshal(out, &sharedCache.GoEnv); err != nil { if err := json.Unmarshal(out, &sharedCache.GoEnv); err != nil {
return fmt.Errorf(`cannot unmarshal from "go env -json": %w`, err) 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 // 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 // to one of the available versions. Given that later we build a patched linker

@ -12,7 +12,7 @@ stderr 'Go version is too old; please upgrade to go1\.25\.0 or newer'
# A clearly invalid go version. # A clearly invalid go version.
env TOOLCHAIN_GOVERSION='bogus version' env TOOLCHAIN_GOVERSION='bogus version'
! exec garble build ! 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; # We should error on a devel version that's too old;
# note that they started with the string "devel", # note that they started with the string "devel",
@ -49,6 +49,12 @@ env TOOLCHAIN_GOVERSION='go1.25.0-somecustomversion'
! exec garble build ! exec garble build
stderr 'mocking the real 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. # The current toolchain may be older than the one that built garble.
env GARBLE_TEST_GOVERSION='go1.25.1' env GARBLE_TEST_GOVERSION='go1.25.1'
env TOOLCHAIN_GOVERSION='go1.25.0' env TOOLCHAIN_GOVERSION='go1.25.0'

Loading…
Cancel
Save