Go version

go version devel go1.23-eaa7d9ff86 Mon Jun 3 14:56:37 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/dagood/.cache/go-build'
GOENV='/home/dagood/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/dagood/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dagood/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dagood/git/golang_go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/dagood/git/golang_go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-eaa7d9ff86 Mon Jun 3 14:56:37 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/dagood/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build443899439=/tmp/go-build -gno-record-gcc-switches'

What did you do?

  1. Get latest Go and build it.
  2. Modify go.env to change the last line to GOTOOLCHAIN=local.
  3. Run bin/go test cmd/go -run=Script/^env_changed$

What did you see happen?

vcs-test.golang.org rerouted to http://127.0.0.1:40965
https://vcs-test.golang.org rerouted to https://127.0.0.1:44551
go test proxy running at GOPROXY=http://127.0.0.1:44935/mod
--- FAIL: TestScript (0.02s)
    --- FAIL: TestScript/env_changed (0.01s)
        script_test.go:135: 2024-06-03T17:14:05Z
        script_test.go:137: $WORK=/tmp/cmd-go-test-2664720355/tmpdir3674230406/env_changed1107368237
        script_test.go:159:
            # Test query for non-defaults in the env (0.007s)
            # linux output like GOTOOLCHAIN='local'
            # windows output like GOTOOLCHAIN=local (0.000s)
            > stdout 'GOTOOLCHAIN=''?local''?'
        script_test.go:159: FAIL: testdata/script/env_changed.txt:13: stdout 'GOTOOLCHAIN=''?local''?': no match for `(?m)GOTOOLCHAIN='?local'?` in stdout
FAIL
FAIL    cmd/go  0.054s
FAIL

The test seems to assume that the default go.env is being used, and "changes" the value to GOTOOLCHAIN=local. However, this isn't a change in my case, so the test fails.

https://github.com/golang/go/blob/eaa7d9ff86b35c72cc35bd7c14b349fa414c392f/src/cmd/go/testdata/script/env_changed.txt

What did you expect to see?

https://go.dev/doc/toolchain suggests that it should be possible for repackaged Go toolchains to change this value, so I expected tests to pass.

I'm not quite familiar enough with TestScript to submit a CL off the top of my head that will make the test conditionally skip based on what go.env already contains, but this is the kind of fix I might expect.

It seems like a better fix would be to have the script use GOTOOLCHAIN local if go.env says auto, and use auto if go.env says local, but this might be too complicated.

The workaround for Go repackagers is simple--patch a skip into this test script when there's a go.env modification. IMO this shouldn't be necessary, though.

Comment From: qiulaidongfeng

I will send fix

Comment From: gopherbot

Change https://go.dev/cl/590196 mentions this issue: cmd/go: avoid when go.env contain GOTOOLCHAIN=local test fail