]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/go: allow suffixed toolchains to satisfy toolchain lines for the same base version
authorBryan C. Mills <bcmills@google.com>
Fri, 13 Oct 2023 20:43:39 +0000 (16:43 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 25 Oct 2023 21:19:11 +0000 (21:19 +0000)
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 <dmitshur@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/go/internal/toolchain/select.go
src/cmd/go/testdata/script/gotoolchain_local.txt

index c3985dedc646204bb0f116030834b1d974f7c6af..9fd1549a61bbc1143747d04291f36b36d2ec5fea 100644 (file)
@@ -167,12 +167,14 @@ func Select() {
                        gover.Startup.AutoToolchain = toolchain
                } else {
                        if toolchain != "" {
-                               // Accept toolchain only if it is >= our min.
+                               // Accept toolchain only if it is > our min.
+                               // (If it is equal, then min satisfies it anyway: that can matter if min
+                               // has a suffix like "go1.21.1-foo" and toolchain is "go1.21.1".)
                                toolVers := gover.FromToolchain(toolchain)
                                if toolVers == "" || (!strings.HasPrefix(toolchain, "go") && !strings.Contains(toolchain, "-go")) {
                                        base.Fatalf("invalid toolchain %q in %s", toolchain, base.ShortPath(file))
                                }
-                               if gover.Compare(toolVers, minVers) >= 0 {
+                               if gover.Compare(toolVers, minVers) > 0 {
                                        gotoolchain = toolchain
                                        minVers = toolVers
                                        gover.Startup.AutoToolchain = toolchain
index 93f557008a64635064dbd65dffee5d03edbbdc12..db7e082db967494060f2557fb25109e30b0a44e0 100644 (file)
@@ -163,12 +163,25 @@ go mod edit -go=1.499 -toolchain=none
 go version
 stdout go1.500-bigcorp
 
+go mod edit -go=1.499 -toolchain=go1.499
+go version
+stdout go1.500-bigcorp
+
 go mod edit -go=1.500 -toolchain=none
 go version
 stdout go1.500-bigcorp
 
+go mod edit -go=1.500 -toolchain=go1.500
+go version
+stdout go1.500-bigcorp
+
 go mod edit -go=1.501 -toolchain=none
 go version
+stdout go1.501
+
+       # If toolchain > go, we must upgrade to the indicated toolchain (not just the go version).
+go mod edit -go=1.499 -toolchain=go1.501
+go version
 stdout go1.501
 
 env TESTGO_VERSION='go1.500 (bigcorp)'