From 9545aa7b51002313cdc37510dd7664c62c99ec06 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 19 Oct 2018 13:50:20 -0400 Subject: [PATCH] go/analysis/cmd/vet: new name for cmd/analyze This is the new vet command. It can be run standalone: $ vet my/project/... or (soon) under go vet: $ GOVETTOOL=$(which vet) go vet my/project/... A forthcoming CL will add support for the second mode, and define a vet-lite command that supports only that mode, but has fewer dependencies; it is intended to be vendored into $GOROOT/src/cmd/vet. Change-Id: I57696ae6d43aa31fd10b370247b7e7497f0f3597 Reviewed-on: https://go-review.googlesource.com/c/143417 Reviewed-by: Michael Matloob Run-TryBot: Michael Matloob --- go/analysis/cmd/{analyze => vet}/README | 0 go/analysis/cmd/{analyze/analyze.go => vet/vet.go} | 6 +++--- go/analysis/doc.go | 12 ++++++------ go/analysis/multichecker/multichecker.go | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) rename go/analysis/cmd/{analyze => vet}/README (100%) rename go/analysis/cmd/{analyze/analyze.go => vet/vet.go} (91%) diff --git a/go/analysis/cmd/analyze/README b/go/analysis/cmd/vet/README similarity index 100% rename from go/analysis/cmd/analyze/README rename to go/analysis/cmd/vet/README diff --git a/go/analysis/cmd/analyze/analyze.go b/go/analysis/cmd/vet/vet.go similarity index 91% rename from go/analysis/cmd/analyze/analyze.go rename to go/analysis/cmd/vet/vet.go index b77bbbd7..ed075c43 100644 --- a/go/analysis/cmd/analyze/analyze.go +++ b/go/analysis/cmd/vet/vet.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// The analyze command is a static checker for Go programs, similar to -// vet, but with pluggable analyzers defined using the analysis -// interface, and using the go/packages API to load packages in any +// The vet command is a static checker for Go programs. It has pluggable +// analyzers defined using the golang.org/x/tools/go/analysis API, and +// using the golang.org/x/tools/go/packages API to load packages in any // build system. // // Each analysis flag name is preceded by the analysis name: --analysis.flag. diff --git a/go/analysis/doc.go b/go/analysis/doc.go index 7ea78079..4223ab80 100644 --- a/go/analysis/doc.go +++ b/go/analysis/doc.go @@ -72,15 +72,15 @@ To add a new Analyzer to an existing driver, add another item to the list: A driver may use the name, flags, and documentation to provide on-line help that describes the analyses its performs. -The "analyze" command, shown below, is an example of a driver that runs +The vet command, shown below, is an example of a driver that runs multiple analyzers. It is based on the multichecker package (see the "Standalone commands" section for details). - $ go build golang.org/x/tools/cmd/analyze - $ ./analyze help - Analyze is a tool for static analysis of Go programs. + $ go build golang.org/x/tools/cmd/vet + $ ./vet help + vet is a tool for static analysis of Go programs. - Usage: analyze [-flag] [package] + Usage: vet [-flag] [package] Registered analyzers: @@ -90,7 +90,7 @@ multiple analyzers. It is based on the multichecker package ... unusedresult check for unused results of calls to some functions - $ ./analyze help unusedresult + $ ./vet help unusedresult unusedresult: check for unused results of calls to some functions Analyzer flags: diff --git a/go/analysis/multichecker/multichecker.go b/go/analysis/multichecker/multichecker.go index a849031e..36e5f825 100644 --- a/go/analysis/multichecker/multichecker.go +++ b/go/analysis/multichecker/multichecker.go @@ -54,8 +54,9 @@ func Main(analyzers ...*analysis.Analyzer) { args := flag.Args() if len(args) == 0 { fmt.Fprintln(os.Stderr, strings.ReplaceAll(usage, "PROGNAME", progname)) - fmt.Fprintf(os.Stderr, `Run '%[1]s help' for more detail, - or '%[1]s help name' for details and flags of a specific analyzer.\n`, progname) + fmt.Fprintf(os.Stderr, "Run '%[1]s help' for more detail,\n"+ + " or '%[1]s help name' for details and flags of a specific analyzer.\n", + progname) os.Exit(1) }