Skip to content

Commit e7908ab

Browse files
Bryan C. Millsgopherbot
authored andcommitted
cmd/go: allow suffixed toolchains to satisfy toolchain lines for the same base version
Fixes #63357. Change-Id: I8380cf0d3965d6aef84a91a515d3e0e8aae9344b Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/535355 Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Bryan Mills <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 55b8e16 commit e7908ab

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/cmd/go/internal/toolchain/select.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ func Select() {
167167
gover.Startup.AutoToolchain = toolchain
168168
} else {
169169
if toolchain != "" {
170-
// Accept toolchain only if it is >= our min.
170+
// Accept toolchain only if it is > our min.
171+
// (If it is equal, then min satisfies it anyway: that can matter if min
172+
// has a suffix like "go1.21.1-foo" and toolchain is "go1.21.1".)
171173
toolVers := gover.FromToolchain(toolchain)
172174
if toolVers == "" || (!strings.HasPrefix(toolchain, "go") && !strings.Contains(toolchain, "-go")) {
173175
base.Fatalf("invalid toolchain %q in %s", toolchain, base.ShortPath(file))
174176
}
175-
if gover.Compare(toolVers, minVers) >= 0 {
177+
if gover.Compare(toolVers, minVers) > 0 {
176178
gotoolchain = toolchain
177179
minVers = toolVers
178180
gover.Startup.AutoToolchain = toolchain

src/cmd/go/testdata/script/gotoolchain_local.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,25 @@ go mod edit -go=1.499 -toolchain=none
163163
go version
164164
stdout go1.500-bigcorp
165165

166+
go mod edit -go=1.499 -toolchain=go1.499
167+
go version
168+
stdout go1.500-bigcorp
169+
166170
go mod edit -go=1.500 -toolchain=none
167171
go version
168172
stdout go1.500-bigcorp
169173

174+
go mod edit -go=1.500 -toolchain=go1.500
175+
go version
176+
stdout go1.500-bigcorp
177+
170178
go mod edit -go=1.501 -toolchain=none
171179
go version
180+
stdout go1.501
181+
182+
# If toolchain > go, we must upgrade to the indicated toolchain (not just the go version).
183+
go mod edit -go=1.499 -toolchain=go1.501
184+
go version
172185
stdout go1.501
173186

174187
env TESTGO_VERSION='go1.500 (bigcorp)'

0 commit comments

Comments
 (0)