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]>
The json/v2 prototype used to support a `format` tag option,
which has been removed for the initial release of json/v2 in Go 1.27.
The wrapper types in this package provide a way to avoid using
the `format` tag option for all existing use-cases.
The types are written to cooperate with other tag options
such as `string`, which may stringify JSON numbers.
We adjust cmd/vet/jsontags accordingly.
Updates #20220
Updates tailscale/corp#45953
Change-Id: Ie1fcea41dc30983e9acc43085f42a6e8ee49d26e
Signed-off-by: Joe Tsai <[email protected]>