-
-
Notifications
You must be signed in to change notification settings - Fork 407
Open
Labels
Description
I have a struct which correctly marshals to and unmarshals from JSON with the following struct tag:
type nodeJSON struct {
// omitted...
Subtract *binaryJSON `json:"-,omitempty"`
// omitted...
}
However, since upgrading to staticcheck v0.7.0, I've been getting this false positive:
internal/json/json.go:112:33: should encoding/json ignore this field or name it "-"? Either use `json:"-"` to ignore the field or use `json:"'-',omitempty"` to specify "-" as the name (SA5008)
As near as I can tell, there's nothing wrong with the current construction. The suggested fix is new syntax that is only available if using the encoding/json/v2 package, which I am not.
Particulars
staticcheck -version:staticcheck 2026.1 (v0.7.0)staticcheck -debug.version:
staticcheck 2026.1 (v0.7.0)
Compiled with Go version: go1.25.6
Main module:
honnef.co/go/tools@v0.7.0 (sum: h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=)
Dependencies:
github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)
golang.org/x/exp/typeparams@v0.0.0-20231108232855-2478ac86f678 (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)
golang.org/x/mod@v0.31.0 (sum: h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=)
golang.org/x/sync@v0.19.0 (sum: h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=)
golang.org/x/tools@v0.40.1-0.20260108161641-ca281cf95054 (sum: h1:CHVDrNHx9ZoOrNN9kKWYIbT5Rj+WF2rlwPkhbQQ5V4U=)
go version:go version go1.25.6 darwin/arm64go env: ... please just let me know any relevant values I should post; I'm not going to post the full thing- Exactly which command you ran:
staticcheck ./internal/json - Output of the command and what's wrong with the output: see above
- Where we can read the code you're running Staticcheck on: https://github.com/cedar-policy/cedar-go/blob/8e2006aedcc55e75ae8750f979ac3d54cc425288/internal/json/json.go#L112
Reactions are currently unavailable