For the last two releases, its output has been the same as 'go -h'.
The test and vet sub-commands share their flag logic via the cmdflag
package, so fixing it there would mean a larger refactor. Moreover, the
test subcommand handles its '-h' flag in a special way; that's #26999.
For now, use a much less invasive fix, mirroring the special-casing of
'test -h' to simply print vet's short usage text.
Also add a regression test via a cmd/go test script.
Fixes #26998.
Change-Id: Ie6b866d98116a1bc5f84a204e1c9f1c2f6b48bff
Reviewed-on: https://go-review.googlesource.com/129318
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
if len(os.Args) > 1 && os.Args[1] == "test" {
test.Usage()
}
+ // Since vet shares code with test in cmdflag, it doesn't show its
+ // command usage properly. For now, special case it too.
+ // TODO(mvdan): fix the cmdflag package instead; see
+ // golang.org/issue/26999
+ if len(os.Args) > 1 && os.Args[1] == "vet" {
+ vet.CmdVet.Usage()
+ }
help.PrintUsage(os.Stderr, base.Go)
os.Exit(2)
}
# go mod --help doesn't print help but at least suggests it.
! go mod --help
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'