]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: additional doc-inspired tests and bug fixes
authorRuss Cox <rsc@golang.org>
Mon, 5 Jun 2023 02:34:52 +0000 (22:34 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 6 Jun 2023 19:18:46 +0000 (19:18 +0000)
commit35268a996052ca8716caf94467c2ed61140f3862
tree4e9b43b9f749a5ead6d098bb825a32c7d4e57219
parentbf016520e2575f8eb5e37634a4ed18c8c8044859
cmd/go: additional doc-inspired tests and bug fixes

Additional tests and bug fixes realized while writing go.dev/doc/gotoolchain (CL 500775).

- Handle go get toolchain@go1.22 (resolve to latest patch release, same as go get go@1.22).
  (See modload/query.go and gover/mod.go.)

- Handle go get go@patch toolchain@patch.
  (See modload/query.go and gover/mod.go.)

- Remove prefix-goVERSION-suffix form for toolchain name,
  standardizing on goVERSION-suffix.
  I have no good explanation for having two forms, so simplify to one.
  (See vendor and gover.)

- Fail toolchain downloads when GOSUMDB=off.
  Because toolchain downloads cannot always be predicted
  (especially during switching rather than selection),
  they cannot be listed in go.sum.
  We rely on the checksum database for integrity of the download,
  especially if proxied. If the checksum database is disabled,
  this integrity check won't happen, so fail toolchain downloads.
  (See modfetch/sumdb.go and script/gotoolchain_net.txt)

- Use names from documentation in package toolchain
  (Select, Switch; SwitchTo renamed to Exec to avoid both names;
  reqs.go renamed to switch.go; toolchain.go renamed to select.go.)

- Make "go env GOTOOLCHAIN" and "go env -w GOTOOLCHAIN"
  work even when GOTOOLCHAIN is misconfigured.
  (See special case at top of Select in select.go.)

- Clarify what goInstallVersion does
  (report whether this is go install or go run pkg@version)
  and explain the potential version switch more clearly.
  Use the Switcher directly instead of reimplementing it.
  (See select.go.)

- Document go@ and toolchain@ forms in go help get,
  linking to go.dev/doc/toolchain.
  (See modget/get.go.)

- Update URL of documentation in $GOROOT/go.env.

For #57001.

Change-Id: I895ef3519ff95db8710ed23b36ebaf4f648120cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/500797
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
16 files changed:
go.env
src/cmd/go/alldocs.go
src/cmd/go/internal/gover/mod.go
src/cmd/go/internal/gover/toolchain.go
src/cmd/go/internal/gover/toolchain_test.go
src/cmd/go/internal/modfetch/sumdb.go
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modload/query.go
src/cmd/go/internal/toolchain/select.go [moved from src/cmd/go/internal/toolchain/toolchain.go with 73% similarity]
src/cmd/go/internal/toolchain/switch.go [moved from src/cmd/go/internal/toolchain/reqs.go with 98% similarity]
src/cmd/go/main.go
src/cmd/go/testdata/script/gotoolchain_local.txt
src/cmd/go/testdata/script/gotoolchain_net.txt
src/cmd/go/testdata/script/mod_edit_toolchain.txt
src/cmd/go/testdata/script/mod_get_toolchain.txt [new file with mode: 0644]
src/cmd/go/testdata/script/work_edit_toolchain.txt