Skip to content

Commit

Permalink
Expand help text for go mod tidy
Browse files Browse the repository at this point in the history
`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]>
  • Loading branch information
mem committed Sep 10, 2022
1 parent 54182ff commit c6e3c8b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cmd/go/internal/modcmd/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ version. By default, tidy acts as if the -compat flag were set to the
version prior to the one indicated by the 'go' directive in the go.mod
file.
go mod tidy works by loading all of the packages in the main module
and all of the packages they import, recursively. This includes
packages imported by tests (including tests in other modules). go mod
tidy acts as if all build tags are enabled, so it will consider
platform-specific source files and files that require custom build
tags, even if those source files wouldn’t normally be built. There is
one exception: the ignore build tag is NOT enabled, so a file with the
build constraint //go:build ignore will not be considered.
See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'.
`,
Run: runTidy,
Expand Down

0 comments on commit c6e3c8b

Please sign in to comment.