Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: cmd/vet: warn about structs marked json omitempty #51261

Open
josharian opened this issue Feb 18, 2022 · 28 comments
Open

proposal: cmd/vet: warn about structs marked json omitempty #51261

josharian opened this issue Feb 18, 2022 · 28 comments
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal
Milestone

Comments

@josharian
Copy link
Contributor

Marking a struct field of type time.Time as json omitempty has no effect. You must use a *time.Time for it to work (which is wire compatible). Vet should detect this situation and perhaps suggest *time.Time instead.

This might be reasonably extended to any struct type; see the linked omitzero proposals for more discussion. If an omitzero proposal is accepted, vet could switch to suggesting the use of omitzero rather than suggesting a pointer type.

cc @dsnet @robpike @dominikh

@dsnet
Copy link
Member

dsnet commented Feb 18, 2022

Scanning all modules, I found ~73k fields where the type was either time.Time or *time.Time with a json:omitempty tag. Approximately 33% were of the former (incorrect) and 66% were of the latter (correct) form.

That's pretty significant evidence that this is a highly frequent problem.

@dominikh
Copy link
Member

Is there any reason to limit this to time.Time instead of applying to all structs?

@dsnet
Copy link
Member

dsnet commented Feb 19, 2022

I advocate expanding it to all structs.

@guodongli-google
Copy link

Yes this shall be extending any non-primitive and non-reference types, mainly struct.

Interestingly, the official document specifies:

Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time.

which actually indicates that a conflicting check that is supposed to report usage of *time.Time in struct fields.
For any time.Time fields, omitempty has no effects. What other harm it can bring other than wasting some storage?

@prattmic
Copy link
Member

I don't write much JSON code, so take my thoughts with a grain of salt, but this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value [1]. It seems rather painful to require use of pointers just to allow omission on the wire.

[1] Admittedly this is still a problem for time.Time, which prefers time.Time.IsZero() over comparison with var zero time.Time.

@dsnet
Copy link
Member

dsnet commented Feb 22, 2022

this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value

I agree there should be some type of omitzero tag that does what the user intends here, but that seems orthogonal to a vet warning that flags incorrect usages of omitempty with a Go struct type.

@guodongli-google
Copy link

this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value

I agree there should be some type of omitzero tag that does what the user intends here, but that seems orthogonal to a vet warning that flags incorrect usages of omitempty with a Go struct type.

It is a little bit confusing what "empty" means. Currently:

The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

Regarding a composite object, what does "empty" or "zero" mean? Consider these cases:

  1. type T struct {}; var o T: obviously o is an empty object.
  2. type T struct { x int; y *int }; var o T;: o is not empty but it is zero.
  3. type T struct { x int}; o := map[int]T{0: T{}};: o is not empty but is it zero?

Users seems to assume that (2) is "empty" when using "omitempty".

@dsnet
Copy link
Member

dsnet commented Feb 22, 2022

I think this issue getting off topic. There's a lot of valid questions with regard to omitzero, omitempty, and their exact semantics, but that discussion belongs in #11939. We should separate "how can json make this better in the future" from "how can we detect incorrect usages today".

@timothy-king
Copy link
Contributor

One concern I have is how to educate users. It seems like the most likely cause is the user misunderstanding of how structs interact with encoding/json with omitempty being a symptom. Vet's message have historically been quite terse. I am hesitant to give suggestions like "rewrite time.Time to *time.Time here" without giving an explanation as to why (and can cause other bugs during the transition). Similarly a message like "struct field %s is not emitted by encoding/json so the omitempty tag is redundant" seems like it would often [usually?] result in the omitempty tag being removed which does not help the underlying confusion.

Do folks have a suggestion for what to tell the user in the diagnostic? What I really want to do is point users at a longer discussion of the issue (like 1-2 paragraphs describing the issue and possible solutions), but to the best of my knowledge this has not done this before in vet.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/388574 mentions this issue: go/analysis/passes/structtag: check option "omitempty" on fields of struct types.

@andig
Copy link
Contributor

andig commented Oct 14, 2023

I think this issue getting off topic
Is there any reason to limit this to time.Time instead of applying to all structs?

I've proposed an implementation for vetting on omitempty in the general case where this is currently a no-op: #63541

We should separate "how can json make this better in the future" from "how can we detect incorrect usages today".

If this issue needs more consideration I'd appreciate if we could reopen #63539 with it's narrower focus.

andig added a commit to andig/go that referenced this issue Oct 14, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/535416 mentions this issue: cmd/go: add vet check for json/xml omitempty struct tags on non-basic types

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/535515 mentions this issue: cmd/go: add vet check for json/xml omitempty struct tags on non-basic types

andig added a commit to andig/go-tools that referenced this issue Oct 16, 2023
… types

Fixes golang/go#51261

Change-Id: Ic71f614acd3a78a9db73483ccefe613cb7f66e5d
andig added a commit to andig/go-tools that referenced this issue Oct 16, 2023
… types

Fixes golang/go#51261

Change-Id: I99c3a0afc5171777b39f8288e2159f8554151e43
@mvdan
Copy link
Member

mvdan commented Jan 10, 2024

I ran face first into this very bug in the x/oauth2 package: https://pkg.go.dev/golang.org/x/oauth2#Token

@mvdan
Copy link
Member

mvdan commented Jan 17, 2024

@rakyll @shinfan @codyoss per https://dev.golang.org/owners - would it be OK to send a patch to make oauth2.Token.Expiry a pointer per the above? It's a v0, so I assume such a breaking change to un-break omitempty would be okay. The alternative would be to wait for encoding/json/v2, which will support this without a pointer, and which is perhaps the best end state in the long run - but we're also blocked for a while.

@codyoss
Copy link
Member

codyoss commented Jan 17, 2024

@mvdan I think even though it is v0 The whole TokenSource interface is quite pervasive in the oauth space. I think we should not make a breaking change here. With how this struct is used I don't think data is actually serialized all that much -- it is much more common to deserialize into it. Does that seem worth the ripple effects imo.

@thw0rted
Copy link

I advocate expanding it to all structs.

Has this issue been expanded to include flagging any inline-struct field that is (uselessly) tagged omitempty? If so, can the title be updated to reflect that? (cc @josharian) If not, should we file a new, broader issue?

We just fixed a bug that bit us in production because our product spent years making API calls, sending JSON that included an extra property with a {} value, and the receiving service finally added data validation that rejected it. We never knew that omitempty on an inline-struct member does nothing, until now....

@andig
Copy link
Contributor

andig commented Feb 12, 2024

@mvdan you're not the first one ;) I'm absolutely puzzled why it seems so hard to move this issue forward?

@timothy-king
Copy link
Contributor

timothy-king commented May 7, 2024

I ran a candidate implementation on a large selection of Go packages with >=10 imports.

I looked at an earlier sample and all of the reports looked accurate. We may want to treat generated code specially though. The candidate implementation is now gated to only warn when it knows that ast.IsGenerated is false. The reports in hand written code all look like warnings someone should fix. The diagnostics in generated code are correct, but I am less confident users will want to take action by changing the generated code. That code might be written over or the generator is hard to fix, etc. The fix is to change the generator, which is a bit of a slower process and not very CICD friendly. Hence the additional IsGenerated requirement in the prototype I added.

Examples this would exclude: 1, 2. Some diagnostics are in generated code that do not yet satisfy IsGenerated (example), but we do need to pick some standard and that is ast.IsGenerated.

I think it would be okay to release the omitempty check in go version N, and remove the IsGenerated check in go version N+1. So I don't think this has to be a requirement forever.

Here are 100 randomly selected diagnostics out of 29697 (no ast.IsGenerated files):
https://go-mod-viewer.appspot.com/github.com/apache/camel-k/pkg/apis/[email protected]/v1/build_types.go#L236: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/khulnasoft-lab/[email protected]/pkg/vulnsrc/oracle-oval/types.go#L13: field IssuedDate has omitempty tag which has no effect on struct type github.com/khulnasoft-lab/tunnel-db/pkg/vulnsrc/oracle-oval.Date
https://go-mod-viewer.appspot.com/github.com/Azure/[email protected]/pkg/apis/aadpodidentity/v1/types.go#L129: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/chnsz/[email protected]/openstack/cce/v3/clusters/results.go#L67: field Authentication has omitempty tag which has no effect on struct type github.com/chnsz/golangsdk/openstack/cce/v3/clusters.AuthenticationSpec
https://go-mod-viewer.appspot.com/github.com/hscells/[email protected]/medgen.go#L18: field XMLName has omitempty tag which has no effect on struct type encoding/xml.Name
https://go-mod-viewer.appspot.com/github.com/percona/[email protected]/pkg/apis/pxc/v1/pxc_types.go#L555: field Resources has omitempty tag which has no effect on struct type k8s.io/api/core/v1.ResourceRequirements
https://go-mod-viewer.appspot.com/github.com/pingcap/tidb-operator/pkg/[email protected]/pingcap/v1alpha1/tidbngmonitoring_types.go#L93: field NGMonitoring has omitempty tag which has no effect on struct type github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.NGMonitoringStatus
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/[email protected]/types.go#L271: field PartialPayment has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.InvoicePartialPayment
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/[email protected]/pkg/apis/ca/v1/ca.go#L157: field FileKeyStore has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/ca/v1.FileKeyStoreOpts
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/internal/third_party/go-json-experiment/json/testdata_test.go#L508: field Entities has omitempty tag which has no effect on struct type k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.twitterEntities
https://go-mod-viewer.appspot.com/github.com/minio/[email protected]/cluster-commands.go#L464: field SSEConfigUpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/giantswarm/apiextensions/[email protected]/pkg/apis/infrastructure/v1alpha2/g8s_control_plane_types.go#L51: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/minio/madmin-go/[email protected]/perf-object.go#L45: field TTFB has omitempty tag which has no effect on struct type github.com/minio/madmin-go/v3.Timings
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L6203: field ServiceLevel has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ServiceLevelDefinition
https://go-mod-viewer.appspot.com/github.com/goreleaser/[email protected]/pkg/config/config.go#L263: field Repository has omitempty tag which has no effect on struct type github.com/goreleaser/goreleaser/pkg/config.RepoRef
https://go-mod-viewer.appspot.com/libvirt.org/go/[email protected]/nwfilter.go#L114: field DstIPTo has omitempty tag which has no effect on struct type libvirt.org/go/libvirtxml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/argoproj-labs/[email protected]/api/v1alpha1/argocd_types.go#L518: field Autoscale has omitempty tag which has no effect on struct type github.com/argoproj-labs/argocd-operator/api/v1alpha1.ArgoCDServerAutoscaleSpec
https://go-mod-viewer.appspot.com/halkyon.io/[email protected]/component/v1beta1/types.go#L193: field Spec has omitempty tag which has no effect on struct type halkyon.io/api/component/v1beta1.ComponentSpec
https://go-mod-viewer.appspot.com/github.com/amimof/[email protected]/capabilities.go#L6: field Lights has omitempty tag which has no effect on struct type github.com/amimof/huego.Capability
https://go-mod-viewer.appspot.com/github.com/charmbracelet/[email protected]/ansi/style.go#L102: field List has omitempty tag which has no effect on struct type github.com/charmbracelet/glamour/ansi.StyleList
https://go-mod-viewer.appspot.com/github.com/saferwall/[email protected]/file.go#L17: field DOSHeader has omitempty tag which has no effect on struct type github.com/saferwall/pe.ImageDOSHeader
https://go-mod-viewer.appspot.com/github.com/kuadrant/[email protected]/api/v1beta2/auth_config_types.go#L618: field SubResource has omitempty tag which has no effect on struct type github.com/kuadrant/authorino/api/v1beta2.ValueOrSelector
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/[email protected]/pkg/appsec/tuning_recommendations.go#L62: field EvaluationPeriodEnd has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/banzaicloud/istio-operator/pkg/[email protected]/istio/v1beta1/istio_types.go#L402: field Init has omitempty tag which has no effect on struct type github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.ProxyInitConfiguration
https://go-mod-viewer.appspot.com/github.com/go-playground/webhooks/[email protected]/github/payload.go#L5664: field Repository has omitempty tag which has no effect on type struct{Name struct{From string "json:"from""} "json:"name""}
https://go-mod-viewer.appspot.com/github.com/twilio/[email protected]/rest/conversations/v1/model_list_conversation_message_receipt_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/conversations/v1.ListConfigurationAddressResponseMeta
https://go-mod-viewer.appspot.com/github.com/argoproj/[email protected]/pkg/apis/eventbus/v1alpha1/eventbus_types.go#L51: field Config has omitempty tag which has no effect on struct type github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.BusConfig
https://go-mod-viewer.appspot.com/github.com/minio/[email protected]/cmd/health_v1.go#L97: field Info has omitempty tag which has no effect on struct type github.com/minio/madmin-go/v3.InfoMessage
https://go-mod-viewer.appspot.com/github.com/rook/rook/pkg/[email protected]/ceph.rook.io/v1/types.go#L779: field StatusCheck has omitempty tag which has no effect on struct type github.com/rook/rook/pkg/apis/ceph.rook.io/v1.MirrorHealthCheckSpec
https://go-mod-viewer.appspot.com/github.com/IBM-Cloud/[email protected]/api/icd/icdv4/auto_scaling.go#L25: field Scalers has omitempty tag which has no effect on struct type github.com/IBM-Cloud/bluemix-go/api/icd/icdv4.ScalersBody
https://go-mod-viewer.appspot.com/github.com/blend/[email protected]/web/config.go#L54: field Views has omitempty tag which has no effect on struct type github.com/blend/go-sdk/web.ViewCacheConfig
https://go-mod-viewer.appspot.com/github.com/nats-io/jwt/[email protected]/decoder_activation.go#L36: field v1NatsActivation has omitempty tag which has no effect on struct type github.com/nats-io/jwt/v2.v1NatsActivation
https://go-mod-viewer.appspot.com/github.com/twilio/[email protected]/rest/taskrouter/v1/model_list_worker_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/taskrouter/v1.ListActivityResponseMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/exp/ipam/api/v1alpha1/ipaddressclaim_types.go#L36: field AddressRef has omitempty tag which has no effect on struct type k8s.io/api/core/v1.LocalObjectReference
https://go-mod-viewer.appspot.com/kubesphere.io/[email protected]/network/v1alpha1/namespacenetworkpolicy_types.go#L140: field Spec has omitempty tag which has no effect on struct type kubesphere.io/api/network/v1alpha1.NamespaceNetworkPolicySpec
https://go-mod-viewer.appspot.com/github.com/aiven/[email protected]/kafka_topic.go#L48: field MinCompactionLagMs has omitempty tag which has no effect on struct type github.com/aiven/aiven-go-client.KafkaTopicConfigResponseInt
https://go-mod-viewer.appspot.com/github.com/dnsimple/[email protected]/dnsimple/billing.go#L28: field TotalAmount has omitempty tag which has no effect on struct type github.com/shopspring/decimal.Decimal
https://go-mod-viewer.appspot.com/github.com/chaos-mesh/chaos-mesh/api/[email protected]/workflownode_types.go#L127: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/cidverse/[email protected]/types.go#L126: field Ref has omitempty tag which has no effect on struct type github.com/cidverse/cid-sdk-go.VCSTag
https://go-mod-viewer.appspot.com/github.com/arienmalec/[email protected]/request.go#L90: field Device has omitempty tag which has no effect on type struct{DeviceID string "json:"deviceId,omitempty""}
https://go-mod-viewer.appspot.com/github.com/opentelekomcloud/[email protected]/openstack/cce/v3/nodepools/requests.go#L172: field Spec has omitempty tag which has no effect on struct type github.com/opentelekomcloud/gophertelekomcloud/openstack/cce/v3/nodepools.UpdateSpec
https://go-mod-viewer.appspot.com/github.com/elastic/[email protected]/cgroup/cpu.go#L16: field CFS has omitempty tag which has no effect on struct type github.com/elastic/gosigar/cgroup.CFS
https://go-mod-viewer.appspot.com/github.com/vmpartner/[email protected]/swagger/instrument.go#L127: field ClosingTimestamp has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/bububa/oceanengine/[email protected]/model/report/video_frame.go#L15: field EndDate has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/FusionAuth/[email protected]/pkg/fusionauth/Domain.go#L1173: field Email has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.MultiFactorEmailMethod
https://go-mod-viewer.appspot.com/github.com/prometheus-operator/prometheus-operator/pkg/apis/[email protected]/v1/probe_types.go#L36: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/wit-ai/wit-go/[email protected]/apps.go#L40: field WillTrainAt has omitempty tag which has no effect on struct type github.com/wit-ai/wit-go/v2.Time
https://go-mod-viewer.appspot.com/github.com/rancher/fleet/pkg/[email protected]/fleet.cattle.io/v1alpha1/cluster_types.go#L159: field Agent has omitempty tag which has no effect on struct type github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1.AgentStatus
https://go-mod-viewer.appspot.com/kubevirt.io/[email protected]/pool/v1alpha1/types.go#L74: field LastProbeTime has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/[email protected]/apis/core.oam.dev/v1alpha1/workloadtype_types.go#L73: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/vmware-tanzu/nsx-operator/pkg/[email protected]/nsx.vmware.com/v1alpha1/subnetset_types.go#L51: field Status has omitempty tag which has no effect on struct type github.com/vmware-tanzu/nsx-operator/pkg/apis/nsx.vmware.com/v1alpha1.SubnetSetStatus
https://go-mod-viewer.appspot.com/github.com/google/go-github/[email protected]/github/repos_contents.go#L48: field Commit has omitempty tag which has no effect on struct type github.com/google/go-github/v49/github.Commit
https://go-mod-viewer.appspot.com/github.com/oam-dev/[email protected]/pkg/velaql/providers/query/handler.go#L75: field Filter has omitempty tag which has no effect on struct type github.com/oam-dev/kubevela/pkg/velaql/providers/query.FilterOption
https://go-mod-viewer.appspot.com/github.com/minio/madmin-go/[email protected]/cluster-commands.go#L482: field TagConfigUpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/internal/apis/core/v1alpha4/machineset_types.go#L227: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/internal/apis/core/exp/v1alpha3/machinepool_types.go#L224: field Spec has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha3.MachinePoolSpec
https://go-mod-viewer.appspot.com/github.com/gophercloud/[email protected]/openstack/identity/v3/roles/results.go#L152: field Project has omitempty tag which has no effect on struct type github.com/gophercloud/gophercloud/openstack/identity/v3/roles.Project
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/cloud/types.go#L2405: field Service has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/cloud.CloudService
https://go-mod-viewer.appspot.com/github.com/prebid/[email protected]/openrtb_ext/floors.go#L92: field Schema has omitempty tag which has no effect on struct type github.com/prebid/prebid-server/openrtb_ext.PriceFloorSchema
https://go-mod-viewer.appspot.com/golift.io/[email protected]/lidarr/artist.go#L39: field Added has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/[email protected]/pkg/addon/type.go#L69: field Notes has omitempty tag which has no effect on struct type github.com/oam-dev/kubevela/pkg/addon.ElementFile
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/[email protected]/types.go#L385: field RecipientAddress has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.InvoiceAddressPortable
https://go-mod-viewer.appspot.com/github.com/goreleaser/[email protected]/pkg/config/config.go#L907: field Scripts has omitempty tag which has no effect on struct type github.com/goreleaser/goreleaser/pkg/config.NFPMArchLinuxScripts
https://go-mod-viewer.appspot.com/github.com/google/[email protected]/info/v2/container.go#L89: field Memory has omitempty tag which has no effect on struct type github.com/google/cadvisor/info/v2.MemorySpec
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L3271: field OrderBy has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.AgentTracesTransactionTraceOrderBy
https://go-mod-viewer.appspot.com/github.com/nicolai86/[email protected]/pkg/api/api.go#L338: field Bootscript has omitempty tag which has no effect on struct type github.com/nicolai86/scaleway-sdk/pkg/api.ScalewayBootscript
https://go-mod-viewer.appspot.com/github.com/libvirt/[email protected]+incompatible/nwfilter.go#L136: field ARPDstMACAddr has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/goccy/[email protected]/test/cover/cover_marshal_text_test.go#L1791: field A has omitempty tag which has no effect on struct type github.com/goccy/go-json/test/cover_test.coverPtrMarshalText
https://go-mod-viewer.appspot.com/github.com/projectcalico/[email protected]/pkg/apis/projectcalico/v3/bgpfilter.go#L43: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/ferryproxy/[email protected]/apis/traffic/v1alpha2/routepolicy_types.go#L95: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/scaleway/[email protected]/pkg/api/api.go#L302: field Snapshot has omitempty tag which has no effect on struct type github.com/scaleway/scaleway-cli/pkg/api.ScalewaySnapshot
https://go-mod-viewer.appspot.com/github.com/kotalco/[email protected]/apis/aptos/v1alpha1/node.go#L60: field Resources has omitempty tag which has no effect on struct type github.com/kotalco/kotal/apis/shared.Resources
https://go-mod-viewer.appspot.com/github.com/kubeshop/[email protected]/pkg/imageinspector/types.go#L42: field FetchedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L8248: field Account has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/accounts.AccountReference
https://go-mod-viewer.appspot.com/github.com/muxinc/[email protected]/model_create_track_response.go#L7: field Data has omitempty tag which has no effect on struct type github.com/muxinc/mux-go.Track
https://go-mod-viewer.appspot.com/github.com/snowflakedb/[email protected]/query.go#L83: field Creds has omitempty tag which has no effect on struct type github.com/snowflakedb/gosnowflake.execResponseCredentials
https://go-mod-viewer.appspot.com/github.com/OpsMx/[email protected]/birger/controller.go#L217: field Credential has omitempty tag which has no effect on type struct{Password string "json:"password,omitempty""}
https://go-mod-viewer.appspot.com/github.com/redhat-appstudio/[email protected]/api/v1alpha1/release_types.go#L163: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/tada-team/[email protected]/billing_team.go#L8: field DeleteDate has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/greenpau/[email protected]/credit_card.go#L30: field IssuedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/stefanmcshane/[email protected]/pkg/release/info.go#L25: field FirstDeployed has omitempty tag which has no effect on struct type github.com/stefanmcshane/helm/pkg/time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/pkg/apis/prowjobs/v1/types.go#L134: field Status has omitempty tag which has no effect on struct type sigs.k8s.io/prow/pkg/apis/prowjobs/v1.ProwJobStatus
https://go-mod-viewer.appspot.com/github.com/verrazzano/[email protected]/pkg/apis/vmcontroller/v1/types.go#L106: field Storage has omitempty tag which has no effect on struct type github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1.Storage
https://go-mod-viewer.appspot.com/github.com/dhax/[email protected]/auth/pwdless/account.go#L17: field CreatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/crossplane/[email protected]/pkg/terraform/files.go#L290: field Terraform has omitempty tag which has no effect on struct type github.com/crossplane/upjet/pkg/terraform.Terraform
https://go-mod-viewer.appspot.com/open-cluster-management.io/[email protected]/api/v1/policy_types.go#L119: field LastTimestamp has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/api/v1beta1/types_template.go#L68: field APIServerLB has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api-provider-azure/api/v1beta1.LoadBalancerClassSpec
https://go-mod-viewer.appspot.com/github.com/dim13/[email protected]/event.go#L340: field HandledTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L10421: field GoldenTags has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.EntityGoldenContextScopedGoldenTags
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/[email protected]/pkg/papi/propertyhostname.go#L59: field CertStatus has omitempty tag which has no effect on struct type github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi.CertStatusItem
https://go-mod-viewer.appspot.com/github.com/ThingsIXFoundation/[email protected]/mapping_discovery_receipt_record.go#L34: field GatewayTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/saferwall/[email protected]/file.go#L34: field CLR has omitempty tag which has no effect on struct type github.com/saferwall/pe.CLRData
https://go-mod-viewer.appspot.com/github.com/sacloud/libsacloud/[email protected]/sacloud/zz_envelopes.go#L3057: field Start has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/kubesphere.io/[email protected]/iam/v1alpha2/types.go#L306: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/schmorrison/[email protected]/crm/users.go#L116: field Profile has omitempty tag which has no effect on type struct{Name string "json:"name,omitempty""; ID string "json:"id,omitempty""}
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/alerts/conditions.go#L356: field Condition has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/alerts.Condition
https://go-mod-viewer.appspot.com/github.com/argoproj/argo-cd/[email protected]/pkg/apis/application/v1alpha1/types.go#L949: field Summary has omitempty tag which has no effect on struct type github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1.ApplicationSummary
https://go-mod-viewer.appspot.com/github.com/FusionAuth/[email protected]/pkg/fusionauth/Domain.go#L4029: field FailedAuthenticationConfiguration has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.FailedAuthenticationConfiguration
https://go-mod-viewer.appspot.com/github.com/k8ssandra/[email protected]/apis/control/v1alpha1/cassandratask_types.go#L189: field Status has omitempty tag which has no effect on struct type github.com/k8ssandra/cass-operator/apis/control/v1alpha1.CassandraTaskStatus
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/[email protected]/pkg/appsec/export_configuration.go#L420: field IPGeoFirewall has omitempty tag which has no effect on type struct{Block string "json:"block""; GeoControls struct{BlockedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"blockedIPNetworkLists""} "json:"geoControls""; IPControls struct{AllowedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"allowedIPNetworkLists""; BlockedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"blockedIPNetworkLists""} "json:"ipControls""; UkraineGeoControls struct{UkraineGeoControl struct{Action string "json:"action""}} "json:"ukraineGeoControl,omitempty""}

@timothy-king
Copy link
Contributor

Here are 100 randomly selected diagnostics out of 35104 (allows ast.IsGenerated files):
https://go-mod-viewer.appspot.com/github.com/libvirt/[email protected]+incompatible/nwfilter.go#L117: field State has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/goharbor/[email protected]/pkg/sdk/v2.0/models/replication_execution.go#L24: field EndTime has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.DateTime
https://go-mod-viewer.appspot.com/github.com/verrazzano/[email protected]/tools/vz/pkg/internal/util/cluster/rancher/catalogapps.go#L20: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/jenkins-x/[email protected]/pkg/apis/jenkins.io/v1/types_environment.go#L48: field Source has omitempty tag which has no effect on struct type github.com/jenkins-x/jx-api/pkg/apis/jenkins.io/v1.EnvironmentRepository
https://go-mod-viewer.appspot.com/github.com/crowdsecurity/[email protected]/pkg/types/event.go#L44: field Appsec has omitempty tag which has no effect on struct type github.com/crowdsecurity/crowdsec/pkg/types.AppsecEvent
https://go-mod-viewer.appspot.com/github.com/jfrog/jfrog-cli-core/[email protected]/artifactory/commands/oc/startbuild.go#L256: field ClientVersion has omitempty tag which has no effect on struct type github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/oc.clientVersion
https://go-mod-viewer.appspot.com/github.com/vmware/go-vcloud-director/[email protected]/types/v56/cse.go#L55: field OccurredAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/verrazzano/[email protected]/platform-operator/controllers/verrazzano/component/clusterapi/clusterapi_overrides.go#L35: field OCI has omitempty tag which has no effect on struct type github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/clusterapi.capiProvider
https://go-mod-viewer.appspot.com/github.com/onosproject/onos-api/[email protected]/onos/config/v3/value.pb.go#L212: field Value has omitempty tag which has no effect on struct type github.com/onosproject/onos-api/go/onos/config/v3.TypedValue
https://go-mod-viewer.appspot.com/github.com/redhat-appstudio/[email protected]/api/v1alpha1/release_types.go#L480: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/kubernetes-csi/external-snapshotter/client/[email protected]/apis/volumesnapshot/v1/types.go#L235: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/[email protected]/pkg/apis/ca/v1/ca.go#L372: field WriteInterval has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/common.Duration
https://go-mod-viewer.appspot.com/github.com/banzaicloud/istio-operator/pkg/[email protected]/istio/v1beta1/istio_types.go#L252: field Egress has omitempty tag which has no effect on struct type github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.GatewayConfiguration
https://go-mod-viewer.appspot.com/github.com/tigera/[email protected]/pkg/apis/projectcalico/v3/policyrecommendationscope.go#L58: field NamespaceSpec has omitempty tag which has no effect on struct type github.com/tigera/api/pkg/apis/projectcalico/v3.PolicyRecommendationScopeNamespaceSpec
https://go-mod-viewer.appspot.com/github.com/LINBIT/[email protected]/client/controllerconfig.go#L23: field Db has omitempty tag which has no effect on struct type github.com/LINBIT/golinstor/client.ControllerConfigDb
https://go-mod-viewer.appspot.com/github.com/verrazzano/[email protected]/application-operator/apis/clusters/v1alpha1/verrazzanoproject_types.go#L35: field Spec has omitempty tag which has no effect on struct type k8s.io/api/networking/v1.NetworkPolicySpec
https://go-mod-viewer.appspot.com/github.com/cloudnative-id/[email protected]/pkg/apis/community/v1alpha1/weekly_types.go#L46: field Spec has omitempty tag which has no effect on struct type github.com/cloudnative-id/community-operator/pkg/apis/community/v1alpha1.WeeklySpec
https://go-mod-viewer.appspot.com/kubesphere.io/[email protected]/types/v1beta1/federatedstatefulset_types.go#L49: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/crosbymichael/[email protected]/gist.go#L26: field UpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/apis/v1alpha2/udproute_types.go#L41: field Status has omitempty tag which has no effect on struct type sigs.k8s.io/gateway-api/apis/v1alpha2.UDPRouteStatus
https://go-mod-viewer.appspot.com/github.com/erda-project/[email protected]/providers/component-protocol/components/kanban/operation.go#L67: field ClientData has omitempty tag which has no effect on struct type github.com/erda-project/erda-infra/providers/component-protocol/components/kanban.OpBoardUpdateClientData
https://go-mod-viewer.appspot.com/github.com/edwarnicke/[email protected]/binapi/pnat/pnat.ba.go#L246: field Match has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/pnat.PnatMatchTuple
https://go-mod-viewer.appspot.com/github.com/daeMOn63/[email protected]/types.go#L238: field DefaultStrategy has omitempty tag which has no effect on struct type github.com/daeMOn63/bitclient.PullRequestStrategy
https://go-mod-viewer.appspot.com/github.com/networkservicemesh/[email protected]/binapi/wireguard/wireguard.ba.go#L770: field Peer has omitempty tag which has no effect on struct type github.com/networkservicemesh/govpp/binapi/wireguard.WireguardPeer
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/[email protected]/types.go#L435: field RefundAmount has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.Money
https://go-mod-viewer.appspot.com/github.com/NpoolPlatform/[email protected]/pkg/db/ent/currency.go#L35: field MarketValueLow has omitempty tag which has no effect on struct type github.com/shopspring/decimal.Decimal
https://go-mod-viewer.appspot.com/github.com/mweagle/[email protected]/lambda_permissions.go#L142: field Filter has omitempty tag which has no effect on struct type github.com/aws/aws-sdk-go/service/s3.NotificationConfigurationFilter
https://go-mod-viewer.appspot.com/github.com/charmbracelet/[email protected]/ansi/style.go#L23: field NameFunction has omitempty tag which has no effect on struct type github.com/charmbracelet/glamour/ansi.StylePrimitive
https://go-mod-viewer.appspot.com/github.com/hscells/[email protected]/medgen.go#L150: field CHierarchyUrl has omitempty tag which has no effect on struct type github.com/hscells/guru.CHierarchyUrl
https://go-mod-viewer.appspot.com/github.com/libvirt/[email protected]+incompatible/nwfilter.go#L135: field ARPSrcMACAddr has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/apis/v1/gatewayclass_types.go#L263: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/drone/[email protected]/manifest/cond.go#L30: field Event has omitempty tag which has no effect on struct type github.com/drone/runner-go/manifest.Condition
https://go-mod-viewer.appspot.com/github.com/crewjam/[email protected]/metadata.go#L405: field ValidUntil has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/GoogleContainerTools/kpt/porch/[email protected]/porch/types_package.go#L28: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/libvirt/[email protected]+incompatible/nwfilter.go#L177: field Match has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/VirtusLab/[email protected]/pkg/apis/virtuslab/v1alpha1/jenkins_types.go#L15: field Master has omitempty tag which has no effect on struct type github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1.JenkinsMaster
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L9304: field Account has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/accounts.AccountOutline
https://go-mod-viewer.appspot.com/github.com/erda-project/[email protected]/providers/component-protocol/components/filter/operation.go#L25: field ClientData has omitempty tag which has no effect on struct type github.com/erda-project/erda-infra/providers/component-protocol/components/filter.OpFilterClientData
https://go-mod-viewer.appspot.com/github.com/subosito/[email protected]/call.go#L25: field EndTime has omitempty tag which has no effect on struct type github.com/subosito/twilio.Timestamp
https://go-mod-viewer.appspot.com/github.com/frankrap/[email protected]/margin_results.go#L37: field CurrencyQTUM has omitempty tag which has no effect on struct type github.com/frankrap/okex-api.MarginCurrency
https://go-mod-viewer.appspot.com/github.com/mundipagg/[email protected]/models/buyer.go#L7: field Document has omitempty tag which has no effect on struct type github.com/mundipagg/boleto-api/models.Document
https://go-mod-viewer.appspot.com/github.com/pivotal-cf/go-pivnet/[email protected]/release_dependencies.go#L19: field Release has omitempty tag which has no effect on struct type github.com/pivotal-cf/go-pivnet/v6.DependentRelease
https://go-mod-viewer.appspot.com/github.com/edwarnicke/[email protected]/binapi/ip/ip.ba.go#L1282: field Table has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/ip.IPTable
https://go-mod-viewer.appspot.com/github.com/twilio/[email protected]/rest/flex/v1/model_list_interaction_channel_invite_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/flex/v1.ListChannelResponseMeta
https://go-mod-viewer.appspot.com/github.com/chnsz/[email protected]/openstack/cdm/v1/job/requests.go#L49: field FromConfigValues has omitempty tag which has no effect on struct type github.com/chnsz/golangsdk/openstack/cdm/v1/job.JobConfigs
https://go-mod-viewer.appspot.com/github.com/algorand/[email protected]/client/v2/common/models/state_proof_sig_slot.go#L9: field Signature has omitempty tag which has no effect on struct type github.com/algorand/go-algorand-sdk/client/v2/common/models.StateProofSignature
https://go-mod-viewer.appspot.com/github.com/openshift/aws-account-operator/pkg/[email protected]/aws/v1alpha1/awsfederatedrole_types.go#L127: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/projectcalico/[email protected]/pkg/apis/projectcalico/v3/profile.go#L43: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/giantswarm/apiextensions/[email protected]/pkg/apis/provider/v1alpha1/status_types.go#L132: field LastTransitionTime has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L5415: field ApmBrowserSummary has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ApmBrowserApplicationSummaryData
https://go-mod-viewer.appspot.com/github.com/PagerDuty/[email protected]/log_entry.go#L34: field Channel has omitempty tag which has no effect on struct type github.com/PagerDuty/go-pagerduty.Channel
https://go-mod-viewer.appspot.com/github.com/ray-project/kuberay/[email protected]/apis/ray/v1alpha1/raycluster_types.go#L135: field DesiredGPU has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/api/resource.Quantity
https://go-mod-viewer.appspot.com/github.com/argoproj-labs/[email protected]/api/v1alpha1/argocd_types.go#L759: field Repo has omitempty tag which has no effect on struct type github.com/argoproj-labs/argocd-operator/api/v1alpha1.ArgoCDRepoSpec
https://go-mod-viewer.appspot.com/github.com/verrazzano/[email protected]/platform-operator/apis/verrazzano/v1alpha1/verrazzano_types.go#L58: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/waldiirawan/apm-agent-go/[email protected]/model/model.go#L634: field Code has omitempty tag which has no effect on struct type github.com/waldiirawan/apm-agent-go/v2/model.ExceptionCode
https://go-mod-viewer.appspot.com/github.com/osrg/[email protected]+incompatible/internal/pkg/config/bgp_configs.go#L1345: field State has omitempty tag which has no effect on struct type github.com/osrg/gobgp/internal/pkg/config.VrfState
https://go-mod-viewer.appspot.com/github.com/polygon-io/[email protected]/rest/models/dividends.go#L168: field PayDate has omitempty tag which has no effect on struct type github.com/polygon-io/client-go/rest/models.Date
https://go-mod-viewer.appspot.com/github.com/spotahome/[email protected]/api/redisfailover/v1/types.go#L52: field Exporter has omitempty tag which has no effect on struct type github.com/spotahome/redis-operator/api/redisfailover/v1.Exporter
https://go-mod-viewer.appspot.com/github.com/instill-ai/[email protected]/pkg/connector/huggingface/v0/structs.go#L99: field Options has omitempty tag which has no effect on struct type github.com/instill-ai/component/pkg/connector/huggingface/v0.Options
https://go-mod-viewer.appspot.com/github.com/docker/[email protected]/api/compose/v1beta1/stack.go#L11: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api/bootstrap/[email protected]/kubeadm/v1beta2/types.go#L87: field ControllerManager has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api/bootstrap/kubeadm/kubeadm/v1beta2.ControlPlaneComponent
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/entities/types.go#L4082: field ErrorGroup has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ErrorTrackingErrorGroup
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/apis/kueue/v1beta1/workload_types.go#L326: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/openebs/[email protected]/pkg/apis/openebs.io/v1alpha1/blockdevice_types.go#L32: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/internal/apis/core/exp/addons/v1alpha4/clusterresourcesetbinding_types.go#L115: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/bootstrap/eks/api/v1alpha4/eksconfig_types.go#L67: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/gravitational/teleport/[email protected]/types/types.pb.go#L1464: field MongoAtlas has omitempty tag which has no effect on struct type github.com/gravitational/teleport/api/types.MongoAtlas
https://go-mod-viewer.appspot.com/github.com/hyperledger/[email protected]/pkg/didcomm/protocol/mediator/models.go#L19: field Timing has omitempty tag which has no effect on struct type github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/decorator.Timing
https://go-mod-viewer.appspot.com/go.ligato.io/vpp-agent/[email protected]/plugins/vpp/binapi/vpp2106/sr/sr.ba.go#L149: field XconnectNhAddr has omitempty tag which has no effect on struct type go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/ip_types.Address
https://go-mod-viewer.appspot.com/github.com/open-cluster-management/[email protected]/pkg/apis/mcm/v1beta1/clusterstatus_types.go#L49: field KlusterletEndpoint has omitempty tag which has no effect on struct type k8s.io/api/core/v1.EndpointAddress
https://go-mod-viewer.appspot.com/github.com/codeready-toolchain/[email protected]/api/v1alpha1/idler_types.go#L80: field Spec has omitempty tag which has no effect on struct type github.com/codeready-toolchain/api/api/v1alpha1.IdlerSpec
https://go-mod-viewer.appspot.com/github.com/wtfutil/[email protected]/modules/newrelic/client/application_hosts.go#L40: field EndUserSummary has omitempty tag which has no effect on struct type github.com/wtfutil/wtf/modules/newrelic/client.ApplicationHostEndUserSummary
https://go-mod-viewer.appspot.com/github.com/osrg/[email protected]+incompatible/internal/pkg/config/bgp_configs.go#L3417: field PrefixLimit has omitempty tag which has no effect on struct type github.com/osrg/gobgp/internal/pkg/config.PrefixLimit
https://go-mod-viewer.appspot.com/github.com/FusionAuth/[email protected]/pkg/fusionauth/Domain.go#L1369: field Phone has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.Requirable
https://go-mod-viewer.appspot.com/github.com/edwarnicke/[email protected]/binapi/mfib_types/mfib_types.ba.go#L145: field Path has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/fib_types.FibPath
https://go-mod-viewer.appspot.com/github.com/kubeflow/[email protected]/pkg/apis/kubeflow.org/v1/pytorch_types.go#L163: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/infobloxopen/[email protected]/objects.go#L154: field Lan2PhysicalSetting has omitempty tag which has no effect on struct type github.com/infobloxopen/infoblox-go-client.PhysicalPortSetting
https://go-mod-viewer.appspot.com/github.com/prometheus-operator/prometheus-operator/pkg/apis/[email protected]/v1/prometheus_types.go#L344: field Resources has omitempty tag which has no effect on struct type k8s.io/api/core/v1.ResourceRequirements
https://go-mod-viewer.appspot.com/github.com/kotovmak/[email protected]/modules/config/config.go#L357: field Animation has omitempty tag which has no effect on struct type github.com/kotovmak/go-admin/modules/config.PageAnimation
https://go-mod-viewer.appspot.com/github.com/kube-logging/logging-operator/pkg/[email protected]/extensions/api/v1alpha1/hosttailer_types.go#L64: field Spec has omitempty tag which has no effect on struct type github.com/kube-logging/logging-operator/pkg/sdk/extensions/api/v1alpha1.HostTailerSpec
https://go-mod-viewer.appspot.com/github.com/hashicorp/[email protected]/clients/cloud-packer-service/stable/2021-04-30/models/hashicorp_cloud_packer_bucket_latest_iteration.go#L41: field CreatedAt has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.DateTime
https://go-mod-viewer.appspot.com/github.com/banzaicloud/[email protected]/pkg/prometheus/servicemonitor.go#L145: field Password has omitempty tag which has no effect on struct type k8s.io/api/core/v1.SecretKeySelector
https://go-mod-viewer.appspot.com/github.com/twilio/[email protected]/rest/chat/v1/model_list_user_channel_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/chat/v1.ListChannelResponseMeta
https://go-mod-viewer.appspot.com/github.com/dgraph-io/[email protected]/graphql/admin/schema.go#L63: field Set has omitempty tag which has no effect on struct type github.com/dgraph-io/dgraph/graphql/admin.gqlSchema
https://go-mod-viewer.appspot.com/kubesphere.io/[email protected]/notification/v2beta2/notificationmanager_types.go#L336: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/golang.org/x/[email protected]/kubernetes/api/types.go#L2394: field ObjectMeta has omitempty tag which has no effect on struct type golang.org/x/build/kubernetes/api.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/sacloud/[email protected]/zz_envelopes.go#L1494: field End has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/[email protected]/pkg/apis/peer/v1/peer.go#L327: field Cert has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/peer/v1.File
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/exp/api/v1alpha4/awsmachinepool_types.go#L207: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/digitalocean/[email protected]/netbox/models/config_context.go#L49: field Created has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.Date
https://go-mod-viewer.appspot.com/github.com/greenpau/[email protected]/pkg/identity/user.go#L66: field LastModified has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/banzaicloud/[email protected]/pkg/resources/overlay.go#L39: field ObjectKey has omitempty tag which has no effect on struct type github.com/banzaicloud/operator-tools/pkg/types.ObjectKey
https://go-mod-viewer.appspot.com/github.com/twilio/[email protected]/rest/chat/v2/model_list_user_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/chat/v2.ListBindingResponseMeta
https://go-mod-viewer.appspot.com/github.com/newrelic/[email protected]/pkg/apiaccess/keys.go#L178: field Key has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/apiaccess.APIKey
https://go-mod-viewer.appspot.com/sigs.k8s.io/[email protected]/apis/kueue/v1alpha1/multikueue_types.go#L81: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/CyCoreSystems/[email protected]+incompatible/events_gen.go#L727: field ReplaceChannel has omitempty tag which has no effect on struct type github.com/CyCoreSystems/ari.ChannelData
https://go-mod-viewer.appspot.com/github.com/minio/[email protected]/cmd/ilm-rule-export.go#L60: field UpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/[email protected]/references/appfile/api/appfile.go#L52: field UpdateTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/r0busta/[email protected]/graph/model/models_gen.go#L9195: field Title has omitempty tag which has no effect on struct type gopkg.in/guregu/null.v4.String
https://go-mod-viewer.appspot.com/github.com/FusionAuth/[email protected]/pkg/fusionauth/Domain.go#L6479: field Field has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.FormField

@thw0rted
Copy link

thw0rted commented Sep 9, 2024

It looks like #11939 was just closed in favor of a new tag, omitzero. As I suggested earlier in the year, I believe the scope of this proposal should be broadened such that the omitempty tag generates a vet / analysis-framework warning any time it is used in a place where it has no meaning, that is, in places where the new omitzero tag should be used instead.

ETA: ...which, I believe, is exactly what the "candidate implementation" / https://go-review.googlesource.com/c/tools/+/388574 was supposed to do. That review is marked as "abandoned" -- any chance of getting the ball rolling again? It looks like this proposal here has to be resolved first...

@ianlancetaylor ianlancetaylor changed the title proposal: cmd/vet: warn about time.Time struct fields marked json omitempty proposal: cmd/vet: warn about structs marked json omitempty Sep 10, 2024
@rsc
Copy link
Contributor

rsc commented Sep 11, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Sep 11, 2024
@andig
Copy link
Contributor

andig commented Sep 11, 2024

Awesome! The fact that even Go standard library likes to promote this mistake speaks for itself. Follow-up proposal would be if "fixing" go standard library goes against compatibility promise (oauth2.Token anyone?).

@aclements
Copy link
Member

As I suggested earlier in the year, I believe the scope of this proposal should be broadened such that the omitempty tag generates a vet / analysis-framework warning any time it is used in a place where it has no meaning, that is, in places where the new omitzero tag should be used instead.

My instinct is that, practically speaking, this is far more of a problem for struct fields than anything else, but I would love to see some data on that. @timothy-king , since you have the pipeline for checking for omitempty struct fields, could you check for meaningless omitempty fields of other kinds?

@dsnet
Copy link
Member

dsnet commented Oct 2, 2024

I should note that the v2 experiment alters the definition of omitempty such that it works and doesn't work in a different set of circumstances: #63397 (comment)

To be specific:

The omitempty option in v2 is redefined relative to v1, and this could cause compatibility issues. Despite the change in semantics, they generally produce the same result in most cases except the following:

  • Go bools and numeric kinds (e.g., int, float32, etc.) cannot be omitted with omitempty in v2 since the proposed definition of an empty JSON value does not include false or 0 (example).
  • Go pointers and interfaces may be omitted in v2 but not v1 if the underlying value encodes as an empty JSON value. For example, an empty string stored in an interface or a non-null pointer to an empty struct will operate differently under v2 semantics (example).

In both cases, the v1 semantics can be obtained by using the omitzero option.

Under the v2 definition, omitempty could be meaningful on a struct type if:

  • that type has a custom MarshalJSON method (which might emit null, "", [], or {}),
  • that type itself has fields with omitzero or omitempty, or
  • that type has no JSON serializable fields (not sure how this is useful).

Under the v2 definition, omitempty is not meaningful on numeric or boolean values (that don't have a MarshalJSON method).

@aclements
Copy link
Member

So.. if we add this vet check now, it'll mess up json/v2 in the future? That's unfortunate.

I believe vet can see all of the conditions for omitempty to be meaningful (or meaningless) in json/v2. Hence, we could implement the basic check for now, and if/when json/v2 lands we can update vet to support the more liberal validity of omitempty used by json/v2. Does that seem reasonable, @dsnet ?

@dsnet
Copy link
Member

dsnet commented Oct 23, 2024

We have 4 conditions:

  1. valid under both v1 and v2
  2. valid under v1 but not valid under v2
  3. not valid under v1 but valid underv2
  4. not valid under both v1 and v2

I believe we should initially implement this vet check in such a way that it only detects case 4.

More concisely, vet reports a problem if:

  • a field is marked with omitempty AND
  • the type of the field does not implement MarshalJSON or MarshalText AND
    • is an array of non-zero length OR
    • a struct type that has at least 1 JSON serializable field not marked by omitempty or omitzero (in other words, this value cannot possibly be serialized as just {}).

In the future (after 2 releases), we can expand it to detect case 2, where:

  • If omitempty is specified on a bool, int, uint, or float, we suggest the use of omitzero instead.

@aclements
Copy link
Member

Thanks. That logic all seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal
Projects
Status: Active
Development

Successfully merging a pull request may close this issue.