-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.22] cmd/go: download 1.X.0 instead of 1.X during …
…toolchain upgrade. This CL modifies the download behavior when downloading a toolchain for 1.21+. Previously, Go would attempt to download 1.X when upgrading the toolchain which would cause the download to fail for 1.21+ since 1.X is an invalid toolchain. We will attempt to download 1.X.0 since that's likely what the user intended. Additionally, we will also now provide a better error message when the user provides a language version instead of a toolchain version for 1.21+. For #66175 For #62278 Fixes #67236 Change-Id: I28f894290a19d8e3cd220e9d70aeca8f4447e5a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/580217 Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit 27ed85d) Reviewed-on: https://go-review.googlesource.com/c/go/+/583915
- Loading branch information
1 parent
adbfb67
commit 00e6815
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
env TESTGO_VERSION=go1.14 | ||
|
||
# check for invalid toolchain in go.mod | ||
go mod init m | ||
go mod edit -go=1.14 -toolchain=go1.22 | ||
! go version | ||
stderr 'go: invalid toolchain: go1.22 is a language version but not a toolchain version \(go1.22.x\)' | ||
|
||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.14 -toolchain=go1.21 | ||
! go version | ||
stderr 'go: invalid toolchain: go1.21 is a language version but not a toolchain version \(go1.21.x\)' | ||
|
||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.14 -toolchain=go1.20 | ||
! go version | ||
stderr 'go: downloading go1.20 ' | ||
|
||
|
||
# check for invalid GOTOOLCHAIN | ||
env GOTOOLCHAIN=go1.14 | ||
go version | ||
stdout 'go1.14' | ||
|
||
env GOTOOLCHAIN=go1.20 | ||
! go version | ||
stderr 'go: downloading go1.20 ' | ||
|
||
env GOTOOLCHAIN=go1.21 | ||
! go version | ||
stderr 'go: invalid toolchain: go1.21 is a language version but not a toolchain version \(go1.21.x\)' | ||
|
||
env GOTOOLCHAIN=go1.22 | ||
! go version | ||
stderr 'go: invalid toolchain: go1.22 is a language version but not a toolchain version \(go1.22.x\)' | ||
|
||
env GOTOOLCHAIN=go1.20+auto | ||
! go version | ||
stderr 'go: downloading go1.20 ' | ||
|
||
env GOTOOLCHAIN=go1.21+auto | ||
! go version | ||
stderr 'go: invalid toolchain: go1.21 is a language version but not a toolchain version \(go1.21.x\)' | ||
|
||
env GOTOOLCHAIN=go1.22+auto | ||
! go version | ||
stderr 'go: invalid toolchain: go1.22 is a language version but not a toolchain version \(go1.22.x\)' | ||
|
||
env GOTOOLCHAIN=go1.21rc3 | ||
! go version | ||
stderr 'go: downloading go1.21rc3 ' | ||
|
||
env GOTOOLCHAIN=go1.22rc2 | ||
! go version | ||
stderr 'go: downloading go1.22rc2 ' | ||
|
||
env GOTOOLCHAIN=go1.66 | ||
! go version | ||
stderr 'go: invalid toolchain: go1.66 is a language version but not a toolchain version \(go1.66.x\)' | ||
|
||
env GOTOOLCHAIN=go1.18beta2 | ||
! go version | ||
stderr 'go: downloading go1.18beta2 ' | ||
|
||
# go1.X is okay for path lookups | ||
env GOTOOLCHAIN=go1.20+path | ||
! go version | ||
stderr 'go: cannot find "go1.20" in PATH' | ||
|
||
env GOTOOLCHAIN=go1.21+path | ||
! go version | ||
stderr 'go: cannot find "go1.21" in PATH' | ||
|
||
env GOTOOLCHAIN=go1.22+path | ||
! go version | ||
stderr 'go: cannot find "go1.22" in PATH' | ||
|
||
# When a toolchain download takes place, download 1.X.0 | ||
env GOTOOLCHAIN=auto | ||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.300 -toolchain=none | ||
! go version | ||
stderr 'go: downloading go1.300.0 ' | ||
|
||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.21 -toolchain=none | ||
! go version | ||
stderr 'go: downloading go1.21.0 ' | ||
|
||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.22 -toolchain=none | ||
! go version | ||
stderr 'go: downloading go1.22.0 ' | ||
|
||
rm go.mod | ||
go mod init m | ||
go mod edit -go=1.15 -toolchain=none | ||
! go version | ||
stderr 'go: downloading go1.15 ' |