Skip to content

Commit

Permalink
cmd/go: provide a more helpful suggestion for "go vet -?"
Browse files Browse the repository at this point in the history
For the command

	go vet -?

the output was,

	usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]
	Run 'go help vet' for details.
	Run 'go tool vet -help' for the vet tool's flags.

but "go help vet" is perfunctory at best. (That's another issue I'm
working on—see https://go-review.googlesource.com/c/tools/+/291909—
but vendoring is required to sort that out.) Add another line and rewrite
a bit to make it actually helpful:

	usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]
	Run 'go help vet' for details.
	Run 'go tool vet help' for a full list of flags and analyzers.
	Run 'go tool vet -help' for an overview.

Change-Id: I9d8580f0573321a57d55875ac3185988ce3eaf64
Reviewed-on: https://go-review.googlesource.com/c/go/+/291929
Trust: Rob Pike <[email protected]>
Run-TryBot: Rob Pike <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
robpike committed Feb 15, 2021
1 parent 66c2709 commit 852ce7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cmd/go/internal/vet/vetflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ func exitWithUsage() {
if vetTool != "" {
cmd = vetTool
}
fmt.Fprintf(os.Stderr, "Run '%s -help' for the vet tool's flags.\n", cmd)
fmt.Fprintf(os.Stderr, "Run '%s help' for a full list of flags and analyzers.\n", cmd)
fmt.Fprintf(os.Stderr, "Run '%s -help' for an overview.\n", cmd)

base.SetExitStatus(2)
base.Exit()
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/go/testdata/script/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ stderr 'Run ''go help mod'' for usage.'
# Earlier versions of Go printed the same as 'go -h' here.
# Also make sure we print the short help line.
! go vet -h
stderr 'usage: go vet'
stderr 'Run ''go help vet'' for details'
stderr 'Run ''go tool vet -help'' for the vet tool''s flags'
stderr 'usage: go vet .*'
stderr 'Run ''go help vet'' for details.'
stderr 'Run ''go tool vet help'' for a full list of flags and analyzers.'
stderr 'Run ''go tool vet -help'' for an overview.'

# Earlier versions of Go printed a large document here, instead of these two
# lines.
Expand Down

0 comments on commit 852ce7c

Please sign in to comment.