Skip to content

Commit 7d9453c

Browse files
committed
go/analysis/internal/analysisflags: update help message
Not all unitchecker tool are vet tools; some are fix tools. Update the verbiage to cover both kinds. Updates golang/go#71859 Change-Id: I770cb7603d53d3db2873631fd69ad8726b99b47b Reviewed-on: https://go-review.googlesource.com/c/tools/+/711820 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
1 parent 59d5230 commit 7d9453c

File tree

1 file changed

+21
-5
lines changed
  • go/analysis/internal/analysisflags

1 file changed

+21
-5
lines changed

go/analysis/internal/analysisflags/help.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,26 @@ import (
1717

1818
const help = `PROGNAME is a tool for static analysis of Go programs.
1919
20-
PROGNAME examines Go source code and reports suspicious constructs,
21-
such as Printf calls whose arguments do not align with the format
22-
string. It uses heuristics that do not guarantee all reports are
23-
genuine problems, but it can find errors not caught by the compilers.
20+
PROGNAME examines Go source code and reports diagnostics for
21+
suspicious constructs or opportunities for improvement.
22+
Diagnostics may include suggested fixes.
23+
24+
An example of a suspicious construct is a Printf call whose arguments
25+
do not align with the format string. Analyzers may use heuristics that
26+
do not guarantee all reports are genuine problems, but can find
27+
mistakes not caught by the compiler.
28+
29+
An example of an opportunity for improvement is a loop over
30+
strings.Split(doc, "\n"), which may be replaced by a loop over the
31+
strings.SplitSeq iterator, avoiding an array allocation.
32+
Diagnostics in such cases may report non-problems,
33+
but should carry fixes that may be safely applied.
34+
35+
For analyzers of the first kind, use "go vet -vettool=PROGRAM"
36+
to run the tool and report diagnostics.
37+
38+
For analyzers of the second kind, use "go fix -fixtool=PROGRAM"
39+
to run the tool and apply the fixes it suggests.
2440
`
2541

2642
// Help implements the help subcommand for a multichecker or unitchecker
@@ -29,7 +45,7 @@ genuine problems, but it can find errors not caught by the compilers.
2945
func Help(progname string, analyzers []*analysis.Analyzer, args []string) {
3046
// No args: show summary of all analyzers.
3147
if len(args) == 0 {
32-
fmt.Println(strings.Replace(help, "PROGNAME", progname, -1))
48+
fmt.Println(strings.ReplaceAll(help, "PROGNAME", progname))
3349
fmt.Println("Registered analyzers:")
3450
fmt.Println()
3551
sort.Slice(analyzers, func(i, j int) bool {

0 commit comments

Comments
 (0)