golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.22k stars 17.7k forks source link

x/website: mod tidy -diff flag missing from https://go.dev/ref/mod#go-mod-tidy #69936

Open bflad opened 1 month ago

bflad commented 1 month ago

Go version

go version go1.23.2 darwin/arm64

Output of go env in your module/workspace:

N/A

What did you do?

I happened to know that go mod tidy -diff was added in 1.23 πŸŽ‰ , but a quick web search for go mod tidy returned https://go.dev/ref/mod#go-mod-tidy, which does not list the new -diff flag. It is correctly shown in cmd/go help text:

$ go mod tidy -help
usage: go mod tidy [-e] [-v] [-x] [-diff] [-go=version] [-compat=version]
Run 'go help mod tidy' for details.
$ go help mod tidy
usage: go mod tidy [-e] [-v] [-x] [-diff] [-go=version] [-compat=version]

Tidy makes sure go.mod matches the source code in the module.
It adds any missing modules necessary to build the current module's
packages and dependencies, and it removes unused modules that
don't provide any relevant packages. It also adds any missing entries
to go.sum and removes any unnecessary ones.

The -v flag causes tidy to print information about removed modules
to standard error.

The -e flag causes tidy to attempt to proceed despite errors
encountered while loading packages.

The -diff flag causes tidy not to modify go.mod or go.sum but
instead print the necessary changes as a unified diff. It exits
with a non-zero code if the diff is not empty.

The -go flag causes tidy to update the 'go' directive in the go.mod
file to the given version, which may change which module dependencies
are retained as explicit requirements in the go.mod file.
(Go versions 1.17 and higher retain more requirements in order to
support lazy module loading.)

The -compat flag preserves any additional checksums needed for the
'go' command from the indicated major Go release to successfully load
the module graph, and causes tidy to error out if that version of the
'go' command would load any imported package from a different module
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.

The -x flag causes tidy to print the commands download executes.

See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'.

What did you see happen?

The command help also points to the website, which doesn't list the flag.

What did you expect to see?

-diff flag documentation added on the website. πŸ˜„ Apologies if this isn't the correct place to file this sort of issue (was just following the directions at the bottom of https://github.com/golang/website/blob/master/README.md#report-issues--send-patches).

gabyhelp commented 1 month ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

bflad commented 1 month ago

For what it's worth, looks like the -x flag is also not documented on the website. πŸ‘

The -x flag causes tidy to print the commands download executes.
shashank-priyadarshi commented 4 weeks ago

@prattmic can I please take this up?

ansaba commented 2 weeks ago

@shashank-priyadarshi , thank you for helping on it. Let us know when it is ready for review. cc: @samthanawalla