Skip to content

Commit c6e3c8b

Browse files
committed
Expand help text for go mod tidy
`go mod tidy` will ignore files with the build constraint `ignore`. This is documented in https://go.dev/ref/mod#go-mod-tidy. While this URL in mentioned in the existing help text, the fact about the special handling of the `ignore` tag is significant enough to be mentioned explicitly in the help text. From the existing link it's not inmediately obvious that this special behavior exists. Take most of the relevant text from the online description and add it to the help text of `go mod tidy`. Fixes: golang#54993 Signed-off-by: Marcelo E. Magallon <[email protected]>
1 parent 54182ff commit c6e3c8b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cmd/go/internal/modcmd/tidy.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ version. By default, tidy acts as if the -compat flag were set to the
4848
version prior to the one indicated by the 'go' directive in the go.mod
4949
file.
5050
51+
go mod tidy works by loading all of the packages in the main module
52+
and all of the packages they import, recursively. This includes
53+
packages imported by tests (including tests in other modules). go mod
54+
tidy acts as if all build tags are enabled, so it will consider
55+
platform-specific source files and files that require custom build
56+
tags, even if those source files wouldn’t normally be built. There is
57+
one exception: the ignore build tag is NOT enabled, so a file with the
58+
build constraint //go:build ignore will not be considered.
59+
5160
See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'.
5261
`,
5362
Run: runTidy,

0 commit comments

Comments
 (0)