You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
andig
changed the title
cmd/go: add vet check for json:omitempty on time.Time
cmd/go: add vet check for json:omitempty on non-basic types
Oct 14, 2023
andig
changed the title
cmd/go: add vet check for json:omitempty on non-basic types
cmd/go: add vet check for json/xml omitempty struct tags on non-basic types
Oct 14, 2023
It's easy to make the mistake of adding
omitempty
struct tags like this (example from https://github.com/golang/oauth2/blob/master/token.go#L50C2-L50C44.):Currently, this does nothing. With encoding/json/v2 it might become
omitzero
.I suggest to add a vet check flagging
omitempty
as error when added onnon-basic types according to encoding/json'stime.Time
isEmptyValue
(https://github.com/golang/go/pull/63533/files#diff-01d931f6d3bbaef911876952770a164229fe8d659b9007f4be9fc1ea12d20abeR306).The text was updated successfully, but these errors were encountered: