This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

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 contain omitempty and 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 with json:"-" to see the new error.
Source
github.com/golang/go/issues/74376

Understand it, then run it

Run it now

Todaygo
// 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