mirror of
https://github.com/golang/go.git
synced 2025-10-19 11:03:18 +00:00

This change unifies the fix and vet subcommands; they use the same run function, action graph, and external tool (-vettool for go vet and -fixtool for go fix). go fix runs the tool with the -fix flag, whereas although go vet also supports -fix, it is not the default. The two tools have different (overlapping) suites of analyzers. The high-level parts are fully parameterized over the vet/fix distinction; the lower-level parts (the action graph) continue to use only the "vet" terminology. The cmd/{vet,fix} executable is referred to as the "tool". The tool is generally invoked in -json mode, regardless of whether -json was requested, so that the tool produces a cacheable JSON blob on stdout. When the go user did not request -json, this blob is parsed and printed to stderr by logic in the go vet command. (Formerly the tool would print diagnostics to stderr, but this interacts poorly with the build cache.) go fix's legacy -fix=fixer,... flag is now a no-op that prints a warning that the flag is obsolete. The unitchecker's -c=n flag (to display n lines of context around each diagnostic) is reimplemented in go vet based on the JSON information, to avoid reliance on the stderr output of the tool. cmd/fix is added to dist's prebuilt set of tools since go fix cannot build it dynamically (though ideally it would). Updates #71859 For #75432 Change-Id: I0a84746720b59d05d662ed57826747c5598dca44 Reviewed-on: https://go-review.googlesource.com/c/go/+/700795 Reviewed-by: Michael Matloob <matloob@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Bypass: Alan Donovan <adonovan@google.com>
822 B
822 B
Tools
Go command
cmd/doc
, and go tool doc
have been deleted. go doc
can be used as
a replacement for go tool doc
: it takes the same flags and arguments and
has the same behavior.
The go fix
command, following the pattern of go vet
in Go 1.10,
now uses the Go analysis framework (golang.org/x/tools/go/analysis
).
This means the same analyzers that provide diagnostics in go vet
can be used to suggest and apply fixes in go fix
.
The go fix
command's historical fixers, all of which were obsolete,
have been removed and replaced by a suite of new analyzers that
offer fixes to use newer features of the language and library.