Commit 3fb9e087 authored by Konstantin Shaposhnikov's avatar Konstantin Shaposhnikov Committed by Russ Cox

cmd/vet: make "-all -shadow" mean all default checks and -shadow

Prior to this change "go tool vet -all -shadow" ran only -shadow check.

Also fix godoc package path in the usage text.

Fixes #13020

Change-Id: I87c60d6b06a02106ae8bff56adb79df032cc4646
Reviewed-on: https://go-review.googlesource.com/16325Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent e0c05fcb
...@@ -178,7 +178,7 @@ Other flags ...@@ -178,7 +178,7 @@ Other flags
These flags configure the behavior of vet: These flags configure the behavior of vet:
-all (default true) -all (default true)
Check everything; disabled if any explicit check is requested. Enable all non-experimental checks.
-v -v
Verbose mode Verbose mode
-printfuncs -printfuncs
......
...@@ -32,9 +32,8 @@ var ( ...@@ -32,9 +32,8 @@ var (
var exitCode = 0 var exitCode = 0
// "all" is here only for the appearance of backwards compatibility. // "-all" flag enables all non-experimental checks
// It has no effect; the triState flags do the work. var all = triStateFlag("all", unset, "enable all non-experimental checks")
var all = flag.Bool("all", true, "check everything; disabled if any explicit check is requested")
// Flags to control which individual checks to perform. // Flags to control which individual checks to perform.
var report = map[string]*triState{ var report = map[string]*triState{
...@@ -169,7 +168,7 @@ func Usage() { ...@@ -169,7 +168,7 @@ func Usage() {
fmt.Fprintf(os.Stderr, "\tvet [flags] directory...\n") 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, "\tvet [flags] files... # Must be a single package\n")
fmt.Fprintf(os.Stderr, "For more information run\n") fmt.Fprintf(os.Stderr, "For more information run\n")
fmt.Fprintf(os.Stderr, "\tgodoc golang.org/x/tools/cmd/vet\n\n") fmt.Fprintf(os.Stderr, "\tgodoc cmd/vet\n\n")
fmt.Fprintf(os.Stderr, "Flags:\n") fmt.Fprintf(os.Stderr, "Flags:\n")
flag.PrintDefaults() flag.PrintDefaults()
os.Exit(2) os.Exit(2)
...@@ -198,8 +197,9 @@ func main() { ...@@ -198,8 +197,9 @@ func main() {
flag.Parse() flag.Parse()
// If any flag is set, we run only those checks requested. // If any flag is set, we run only those checks requested.
// If no flags are set true, set all the non-experimental ones not explicitly set (in effect, set the "-all" flag). // If all flag is set true or if no flags are set true, set all the non-experimental ones
if setTrueCount == 0 { // not explicitly set (in effect, set the "-all" flag).
if setTrueCount == 0 || *all == setTrue {
for name, setting := range report { for name, setting := range report {
if *setting == unset && !experimental[name] { if *setting == unset && !experimental[name] {
*setting = setTrue *setting = setTrue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment