Radar · Go · Archive · Week 33 · Aug 11 – 17, 2025
x/tools/go/analysis/structtag: stricter JSON tag checking
Worth knowingtooling
- What changed
- The structtag analyzer now checks for JSON tags that are a single dash (
"-") or containomitemptyand reports them as errors. - Production impact
- The source does not say.
- Try it
- Run
go vet ./...on a project that has a struct field tagged withjson:"-"to see the new error. - Source
- github.com/golang/go/issues/74376
Understand it, then run it
Run it now
// This program demonstrates the new structtag analyzer behavior.
// It defines a struct with a JSON tag that is a single dash ("-").
// When run with `go vet`, the analyzer will report an error for this tag.
// The program itself compiles and runs fine; the error is only in static analysis.
package main
import (
"encoding/json"
"fmt"
)
type Example struct {
Secret string `json:"-"`
}
func main() {
e := Example{Secret: "hidden"}
b, _ := json.Marshal(e)
fmt.Println(string(b)) // prints {}
}
What it printed when we ran it on Go 1.27.1
{}
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed