cmd/go: document input formats for edit -go / -toolchain

For #73744
For #77888

Change-Id: I95cf52829e79f7c82578fb7aae4064626a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/766481
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Sean Liao 2026-04-13 17:07:34 +01:00
parent 2aa62e3d90
commit f512621129
3 changed files with 20 additions and 4 deletions

View file

@ -1254,10 +1254,14 @@
//
// The -go=version flag sets the expected Go language version.
// This flag is mainly for tools that understand Go version dependencies.
// It takes a version like "1.26" or "1.26.2".
// Using the version "none" removes the go directive.
// Users should prefer 'go get go@version'.
//
// The -toolchain=version flag sets the Go toolchain to use.
// The -toolchain=name flag sets the Go toolchain to use.
// This flag is mainly for tools that understand Go version dependencies.
// It takes a toolchain name like "go1.26" or "go1.26.2".
// Using the name "none" removes the toolchain directive.
// Users should prefer 'go get toolchain@version'.
//
// The -exclude=path@version and -dropexclude=path@version flags
@ -1602,7 +1606,7 @@
//
// The -fmt flag reformats the go.work file without making other changes.
// This reformatting is also implied by any other modifications that use or
// rewrite the go.mod file. The only time this flag is needed is if no other
// rewrite the go.work file. The only time this flag is needed is if no other
// flags are specified, as in 'go work edit -fmt'.
//
// The -godebug=key=value flag adds a godebug key=value line,
@ -1630,8 +1634,12 @@
// editing flags may be repeated, and the changes are applied in the order given.
//
// The -go=version flag sets the expected Go language version.
// It takes a version like "1.26" or "1.26.2".
// Using "none" as the version removes the go directive.
//
// The -toolchain=name flag sets the Go toolchain to use.
// It takes a toolchain name like "go1.26" or "go1.26.2".
// Using "none" as the name removes the toolchain directive.
//
// The -print flag prints the final go.work in its text format instead of
// writing it back to go.work.

View file

@ -60,10 +60,14 @@ constraints imposed by other modules.
The -go=version flag sets the expected Go language version.
This flag is mainly for tools that understand Go version dependencies.
It takes a version like "1.26" or "1.26.2".
Using the version "none" removes the go directive.
Users should prefer 'go get go@version'.
The -toolchain=version flag sets the Go toolchain to use.
The -toolchain=name flag sets the Go toolchain to use.
This flag is mainly for tools that understand Go version dependencies.
It takes a toolchain name like "go1.26" or "go1.26.2".
Using the name "none" removes the toolchain directive.
Users should prefer 'go get toolchain@version'.
The -exclude=path@version and -dropexclude=path@version flags

View file

@ -35,7 +35,7 @@ The editing flags specify a sequence of editing operations.
The -fmt flag reformats the go.work file without making other changes.
This reformatting is also implied by any other modifications that use or
rewrite the go.mod file. The only time this flag is needed is if no other
rewrite the go.work file. The only time this flag is needed is if no other
flags are specified, as in 'go work edit -fmt'.
The -godebug=key=value flag adds a godebug key=value line,
@ -63,8 +63,12 @@ The -use, -dropuse, -replace, and -dropreplace,
editing flags may be repeated, and the changes are applied in the order given.
The -go=version flag sets the expected Go language version.
It takes a version like "1.26" or "1.26.2".
Using "none" as the version removes the go directive.
The -toolchain=name flag sets the Go toolchain to use.
It takes a toolchain name like "go1.26" or "go1.26.2".
Using "none" as the name removes the toolchain directive.
The -print flag prints the final go.work in its text format instead of
writing it back to go.work.