Files
tailscale/cmd/tsvet
Brad Fitzpatrick f11f3e9307 cmd/tsvet: add MainWith, skip cgo-generated files, add jsonduration
Other repos building on package tsvet had to modify its analyzers in
place to turn some off or skip some packages, and to not report
problems in files that cgo generates from C declarations.

Add MainWith, which runs exactly the given analyzers, so callers can
filter or wrap Analyzers instead. Drop diagnostics in cgo-generated
files for all analyzers.

deferrecover reported recover in function literals assigned to
variables that are deferred, such as "f := func() { recover() };
defer f()". Treat a function literal assigned to a variable as deferred
if the variable is ever deferred or is used other than by calling it
(including parameters, results, and package-level variables), as it
may then be deferred elsewhere.

Add jsonduration from tailscale/corp, which reports JSON-tagged
time.Duration fields, which need a jsonformat wrapper type to be
encoded the same way by encoding/json/v2. Fields only encoded by v1
encoding/json, as integer nanoseconds, can instead be declared with the
new jsonformat.DurationAsIntegerNanos alias for time.Duration, which
isn't an API change. Do so for the four existing ones.

That makes tailcfg and others depend on jsonformat, so make jsonformat
use encoding/json/v2 directly, rather than go-json-experiment's aliases
for it.

Updates #22811

Change-Id: I53c1bf4febb6b4c223b6697dfd9a502ee2e96051
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 06:50:29 -08:00
..