cmd/go: toolchain selection interacts unexpectedly with non-standard toolchains #63357
Labels
FrozenDueToAge
GoCommand
cmd/go
modules
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Consider a non-standard toolchain with a Go version like "go1.21.1 X:loopvar" or "go1.21.1-issue63357", and a toolchain directive with the value "go1.21.1" exactly. When I first ran into this, it wasn't immediately clear to me if it would be better for that to cause the released Go toolchain "go1.21.1" to be downloaded and used, or for the non-standard toolchain to be deemed equal. Both options have some upsides. But whichever it is, it should be possible to figure out from the docs.
Consider that https://go.dev/doc/toolchain#version and https://go.dev/doc/toolchain#name include:
And https://go.dev/doc/toolchain#select includes:
So the documentation suggests the answer is they should be considered equal, at least for "go1.21.1-issue63357", and from briefly asking @rsc about this he expected that a non-standard toolchain built with a non-default GOEXPERIMENT isn't different enough to trigger toolchain downloads either.
What did you do?
Details about two types of non-standard toolchain
Using go1.21.1 as base:
And becoming non-standard by either simplify giving its version a suffix:
Or building the toolchain with some GOEXPERIMENT:
$ cd src $ GOEXPERIMENT=loopvar ./make.bash $ ../bin/go version go version go1.21.1 X:loopvar darwin/arm64
In both cases you get a toolchain that's very similar to the standard go1.21.1, but both
go version
andruntime.Version()
report strings that are not equal to the string "go1.21.1".To reproduce this issue, I built a non-standard toolchain "go1.21.1-issue63357" (that said, the same behavior can be reproduced with a non-standard toolchain like "go1.21.1 X:loopvar"):
Which results in the go.mod file:
Then I ran
go version
to see what toolchain would be selected.What did you expect to see?
Expected the local non-standard toolchain to be used, Go version "go1.21.1-issue63357", and no toolchain download to be triggered:
What did you see instead?
It triggered a toolchain download of "go1.21.1" and selected that one instead:
CC @rsc, @bcmills, @matloob.
The text was updated successfully, but these errors were encountered: