-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
Running
go tool modernize -omitzero -fix ./...
will always result in messages like this:
modernize: omitzero@github.com/evcc-io/evcc/core: ignoring alternative fix "Replace omitempty with omitzero (behavior change)"
While the message itself is clear, I'd like to make the replacement instead of removing the annotation. Cli docs say:
However, some other serialization packages (notably kubebuilder, see
https://book.kubebuilder.io/reference/markers.html) may have their own
interpretation of thejson:",omitzero"tag, so removing it may affect
program behavior. For this reason, the omitzero modernizer will not
make changes in any package that contains +kubebuilder annotations.
Replacing
omitemptywithomitzerois a change in behavior. The
original code would always encode the struct field, whereas the
modified code will omit it if it is a zero-value.
I'm not in a kube environment and it is not clear, how the alternative fix can be enforced.