]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/gover: fix ModIsPrerelease for toolchain versions
authorMichael Matloob <matloob@golang.org>
Tue, 29 Jul 2025 21:12:24 +0000 (17:12 -0400)
committerMichael Matloob <matloob@google.com>
Wed, 30 Jul 2025 20:18:24 +0000 (13:18 -0700)
We forgot to call the IsPrerelease function on FromToolchain(vers)
rather than on vers itself. IsPrerelase expects a version without the
"go" prefix. See the corresponding code in ModIsValid and ModIsPrefix
that call FromToolchain before passing the versions to IsValid and
IsLang respectively.

Fixes #74786

Change-Id: I3cf055e1348e6a9dc0334e414f06fe85eaf78024
Reviewed-on: https://go-review.googlesource.com/c/go/+/691655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/go/internal/gover/mod.go
src/cmd/go/testdata/script/mod_get_toolchain.txt

index d3cc17068def6d19cc51f4a25a2a61b1bbd543a9..3ac5ae8824b2337e219060720034499cc3056c8f 100644 (file)
@@ -109,6 +109,9 @@ func ModIsPrefix(path, vers string) bool {
 // The caller is assumed to have checked that ModIsValid(path, vers) is true.
 func ModIsPrerelease(path, vers string) bool {
        if IsToolchain(path) {
+               if path == "toolchain" {
+                       return IsPrerelease(FromToolchain(vers))
+               }
                return IsPrerelease(vers)
        }
        return semver.Prerelease(vers) != ""
index 87e84ae15ef9872d1380c1fc33a4cd5ed1c3739a..83cef4a0fd0c5edd16ac426a3407829cd1413aaf 100644 (file)
@@ -94,12 +94,14 @@ stderr '^go: added toolchain go1.24rc1$'
 grep 'go 1.22.9' go.mod  # no longer implied
 grep 'toolchain go1.24rc1' go.mod
 
-# go get toolchain@latest finds go1.999testmod.
+# go get toolchain@latest finds go1.23.9.
 cp go.mod.orig go.mod
 go get toolchain@latest
-stderr '^go: added toolchain go1.999testmod$'
+stderr '^go: added toolchain go1.23.9$'
 grep 'go 1.21' go.mod
-grep 'toolchain go1.999testmod' go.mod
+grep 'toolchain go1.23.9' go.mod
+
+
 
 # Bug fixes.
 
@@ -115,7 +117,7 @@ stderr '^go: upgraded go 1.19 => 1.21.0'
 
 # go get toolchain@1.24rc1 is OK too.
 go get toolchain@1.24rc1
-stderr '^go: downgraded toolchain go1.999testmod => go1.24rc1$'
+stderr '^go: upgraded toolchain go1.23.9 => go1.24rc1$'
 
 # go get go@1.21 should work if we are the Go 1.21 language version,
 # even though there's no toolchain for it.