Skip to content

Commit 69338a3

Browse files
committed
cmd/go/internal/gover: fix ModIsPrerelease for toolchain versions
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 <[email protected]> Auto-Submit: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent cedf636 commit 69338a3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/cmd/go/internal/gover/mod.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func ModIsPrefix(path, vers string) bool {
109109
// The caller is assumed to have checked that ModIsValid(path, vers) is true.
110110
func ModIsPrerelease(path, vers string) bool {
111111
if IsToolchain(path) {
112+
if path == "toolchain" {
113+
return IsPrerelease(FromToolchain(vers))
114+
}
112115
return IsPrerelease(vers)
113116
}
114117
return semver.Prerelease(vers) != ""

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ stderr '^go: added toolchain go1.24rc1$'
9494
grep 'go 1.22.9' go.mod # no longer implied
9595
grep 'toolchain go1.24rc1' go.mod
9696

97-
# go get toolchain@latest finds go1.999testmod.
97+
# go get toolchain@latest finds go1.23.9.
9898
cp go.mod.orig go.mod
9999
go get toolchain@latest
100-
stderr '^go: added toolchain go1.999testmod$'
100+
stderr '^go: added toolchain go1.23.9$'
101101
grep 'go 1.21' go.mod
102-
grep 'toolchain go1.999testmod' go.mod
102+
grep 'toolchain go1.23.9' go.mod
103+
104+
103105

104106
# Bug fixes.
105107

@@ -115,7 +117,7 @@ stderr '^go: upgraded go 1.19 => 1.21.0'
115117

116118
# go get [email protected] is OK too.
117119
118-
stderr '^go: downgraded toolchain go1.999testmod => go1.24rc1$'
120+
stderr '^go: upgraded toolchain go1.23.9 => go1.24rc1$'
119121

120122
# go get [email protected] should work if we are the Go 1.21 language version,
121123
# even though there's no toolchain for it.

0 commit comments

Comments
 (0)