From: Rob Pike Date: Mon, 4 Apr 2016 20:22:34 +0000 (-0700) Subject: cmd/vet: improve documentation for flags, slightly X-Git-Tag: go1.7beta1~763 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d1feddb7ae6389ee4175ee85b7168cf58a04b952;p=gostls13.git cmd/vet: improve documentation for flags, slightly The way that -all works was unclear from the documentation and made worse by recent changes to the flag package. Improve matters by making the help message say "default true" for the tests that do default to true, and tweak some of the wording. Before: Usage of vet: vet [flags] directory... vet [flags] files... # Must be a single package For more information run go doc cmd/vet Flags: -all enable all non-experimental checks (default unset) -asmdecl check assembly against Go declarations (default unset) ... After: Usage of vet: vet [flags] directory... vet [flags] files... # Must be a single package By default, -all is set and all non-experimental checks are run. For more information run go doc cmd/vet Flags: -all enable all non-experimental checks (default true) -asmdecl check assembly against Go declarations (default true) ... Change-Id: Ie94b27381a9ad2382a10a7542a93bce1d59fa8f5 Reviewed-on: https://go-review.googlesource.com/21495 Reviewed-by: Andrew Gerrand --- diff --git a/src/cmd/vet/doc.go b/src/cmd/vet/doc.go index 2b5e8fcb59..c697f3bc36 100644 --- a/src/cmd/vet/doc.go +++ b/src/cmd/vet/doc.go @@ -29,11 +29,10 @@ check every possible problem and depends on unreliable heuristics so it should be used as guidance only, not as a firm indicator of program correctness. -By default all checks are performed. If any flags are explicitly set -to true, only those tests are run. Conversely, if any flag is -explicitly set to false, only those tests are disabled. -Thus -printf=true runs the printf check, -printf=false runs all checks -except the printf check. +By default the -all flag is set so all checks are performed. +If any flags are explicitly set to true, only those tests are run. Conversely, if +any flag is explicitly set to false, only those tests are disabled. Thus -printf=true +runs the printf check, -printf=false runs all checks except the printf check. Available checks: @@ -194,4 +193,4 @@ These flags configure the behavior of vet: -shadowstrict Whether to be strict about shadowing; can be noisy. */ -package main // import "golang.org/x/tools/cmd/vet" +package main diff --git a/src/cmd/vet/main.go b/src/cmd/vet/main.go index a2142dcabb..8212a14f03 100644 --- a/src/cmd/vet/main.go +++ b/src/cmd/vet/main.go @@ -100,7 +100,7 @@ func (ts *triState) Set(value string) error { func (ts *triState) String() string { switch *ts { case unset: - return "unset" + return "true" // An unset flag will be set by -all, so defaults to true. case setTrue: return "true" case setFalse: @@ -164,6 +164,7 @@ func Usage() { fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) fmt.Fprintf(os.Stderr, "\tvet [flags] directory...\n") fmt.Fprintf(os.Stderr, "\tvet [flags] files... # Must be a single package\n") + fmt.Fprintf(os.Stderr, "By default, -all is set and all non-experimental checks are run.\n") fmt.Fprintf(os.Stderr, "For more information run\n") fmt.Fprintf(os.Stderr, "\tgo doc cmd/vet\n\n") fmt.Fprintf(os.Stderr, "Flags:\n")