go/doc/next
Alan Donovan 6f4c63ba63 cmd/go: unify "go fix" and "go vet"
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>
2025-10-10 13:10:21 -07:00
..
6-stdlib cmd/go, testing: add TB.ArtifactDir and -artifacts flag 2025-10-07 14:39:32 -07:00
1-intro.md doc/next: initialize 2025-07-23 11:41:17 -07:00
2-language.md doc/go_spec.html: document new(expr) 2025-09-23 12:08:27 -07:00
3-tools.md cmd/go: unify "go fix" and "go vet" 2025-10-10 13:10:21 -07:00
4-runtime.md doc/next: initialize 2025-07-23 11:41:17 -07:00
5-toolchain.md cmd/dist: require Go 1.24.6 as minimum bootstrap toolchain 2025-08-11 14:25:55 -07:00
7-ports.md all: remove support for windows/arm 2025-08-06 14:28:12 -07:00