From: thepudds Date: Tue, 11 Feb 2025 17:59:54 +0000 (-0500) Subject: cmd/go: document -modfile and other flags for 'go tool' X-Git-Tag: go1.25rc1~1069 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b574590c36b7ede1492239db2d55c35e8818c7a7;p=gostls13.git cmd/go: document -modfile and other flags for 'go tool' Mention -modfile, -C, -overlay, and -modcacherw in the 'go tool' documentation. We let a reference to 'go help build' give a pointer to more detailed information. The -modfile flag in particular is newly useful with the Go 1.24 support for user-defined tools with 'go tool'. Updates #48429 Updates #33926 Updates #71663 Fixes #71502 Change-Id: Ida67df50ff774a0886733d661a40e27c2cadc0f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/648577 LUCI-TryBot-Result: Go LUCI Reviewed-by: Conrad Irwin Reviewed-by: Michael Matloob Reviewed-by: Sam Thanawalla Auto-Submit: Sam Thanawalla --- diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 7289b5f4b1..fc85995373 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1953,6 +1953,13 @@ // The -n flag causes tool to print the command that would be // executed but not execute it. // +// The -modfile=file.mod build flag causes tool to use an alternate file +// instead of the go.mod in the module root directory. +// +// Tool also provides the -C, -overlay, and -modcacherw build flags. +// +// For more about build flags, see 'go help build'. +// // For more about each builtin tool command, see 'go doc cmd/'. // // # Print Go version diff --git a/src/cmd/go/internal/tool/tool.go b/src/cmd/go/internal/tool/tool.go index 64c40adab2..7033eb1d9c 100644 --- a/src/cmd/go/internal/tool/tool.go +++ b/src/cmd/go/internal/tool/tool.go @@ -46,6 +46,13 @@ With no arguments it prints the list of known tools. The -n flag causes tool to print the command that would be executed but not execute it. +The -modfile=file.mod build flag causes tool to use an alternate file +instead of the go.mod in the module root directory. + +Tool also provides the -C, -overlay, and -modcacherw build flags. + +For more about build flags, see 'go help build'. + For more about each builtin tool command, see 'go doc cmd/'. `, }