Skip to content

Commit d1feddb

Browse files
committed
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 <[email protected]>
1 parent a4650a2 commit d1feddb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/cmd/vet/doc.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ check every possible problem and depends on unreliable heuristics
2929
so it should be used as guidance only, not as a firm indicator of
3030
program correctness.
3131
32-
By default all checks are performed. If any flags are explicitly set
33-
to true, only those tests are run. Conversely, if any flag is
34-
explicitly set to false, only those tests are disabled.
35-
Thus -printf=true runs the printf check, -printf=false runs all checks
36-
except the printf check.
32+
By default the -all flag is set so all checks are performed.
33+
If any flags are explicitly set to true, only those tests are run. Conversely, if
34+
any flag is explicitly set to false, only those tests are disabled. Thus -printf=true
35+
runs the printf check, -printf=false runs all checks except the printf check.
3736
3837
Available checks:
3938
@@ -194,4 +193,4 @@ These flags configure the behavior of vet:
194193
-shadowstrict
195194
Whether to be strict about shadowing; can be noisy.
196195
*/
197-
package main // import "golang.org/x/tools/cmd/vet"
196+
package main

src/cmd/vet/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (ts *triState) Set(value string) error {
100100
func (ts *triState) String() string {
101101
switch *ts {
102102
case unset:
103-
return "unset"
103+
return "true" // An unset flag will be set by -all, so defaults to true.
104104
case setTrue:
105105
return "true"
106106
case setFalse:
@@ -164,6 +164,7 @@ func Usage() {
164164
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
165165
fmt.Fprintf(os.Stderr, "\tvet [flags] directory...\n")
166166
fmt.Fprintf(os.Stderr, "\tvet [flags] files... # Must be a single package\n")
167+
fmt.Fprintf(os.Stderr, "By default, -all is set and all non-experimental checks are run.\n")
167168
fmt.Fprintf(os.Stderr, "For more information run\n")
168169
fmt.Fprintf(os.Stderr, "\tgo doc cmd/vet\n\n")
169170
fmt.Fprintf(os.Stderr, "Flags:\n")

0 commit comments

Comments
 (0)