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 · 25 comments
Open

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

josharian opened this issue Feb 18, 2022 · 25 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/camel@v1.12.1/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/tunnel-db@v0.0.0-20231117205118-74e1113bd007/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/aad-pod-identity@v1.8.17/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/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/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/guru@v0.0.0-20200207042420-2dabeb950d69/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/percona-xtradb-cluster-operator@v1.14.0/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/apis@v1.5.3/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/v4@v4.7.1/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/fabric-operator@v1.0.4/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/kube-openapi@v0.0.0-20240430033511-f0e62f92d13f/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/madmin-go@v1.7.5/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/v2@v2.6.2/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/v3@v3.0.51/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/newrelic-client-go@v1.1.0/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/goreleaser@v1.25.1/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/libvirtxml@v1.10003.0/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/argocd-operator@v0.10.0/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/api@v1.0.0-rc.6/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/huego@v1.2.1/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/glamour@v0.7.0/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/pe@v1.5.2/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/authorino@v0.17.2/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/v8@v8.1.0/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/apis@v0.10.8/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/v6@v6.3.0/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/twilio-go@v1.20.1/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/argo-events@v1.9.1/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/mc@v0.0.0-20240503112107-b471de8d1882/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/apis@v0.0.0-20240506202243-c908f01e97b3/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/bluemix-go@v0.0.0-20240423071914-9e96525baef4/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/go-sdk@v1.20220411.3/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/v2@v2.5.6/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/twilio-go@v1.20.1/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/cluster-api@v1.7.1/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/api@v0.0.0-20231107125330-c9a03957060c/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/aiven-go-client@v1.36.0/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/dnsimple-go@v1.7.0/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/v1alpha1@v0.0.0-20220226050744-799408773657/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/cid-sdk-go@v0.0.0-20240318001225-c193d83f053e/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/alexa-go@v0.0.0-20181025212142-975687393e90/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/gophertelekomcloud@v0.9.3/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/gosigar@v0.14.3/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/bitmex@v1.1.0/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/marketing-api@v0.0.0-20210315120513-0b953137f7a6/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/go-client@v0.0.0-20240425220342-2317e10dfcf5/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/monitoring@v0.73.2/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/v2@v2.0.2/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/apis@v0.9.4/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/api@v1.2.0/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/oam-go-sdk@v0.0.0-20210317082903-d46a6aee5e38/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/apis@v1.0.0/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/v49@v49.1.0/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/kubevela@v1.9.11/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/v2@v2.2.1/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/cluster-api@v1.7.1/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/cluster-api@v1.7.1/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/gophercloud@v1.11.0/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/newrelic-client-go@v1.1.0/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/prebid-server@v0.275.0/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/starr@v1.0.0/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/kubevela@v1.9.11/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/v4@v4.7.1/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/goreleaser@v1.25.1/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/cadvisor@v0.49.1/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/newrelic-client-go@v1.1.0/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/scaleway-sdk@v1.11.1/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/libvirt-go-xml@v7.4.0+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/go-json@v0.10.2/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/api@v0.0.0-20231218190037-9183ab93f33e/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/api@v0.4.2/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/scaleway-cli@v1.11.1/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/kotal@v0.3.0/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/testkube@v1.17.23/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/newrelic-client-go@v1.1.0/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/mux-go@v1.1.1/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/gosnowflake@v1.9.0/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/go-app-base@v0.0.24/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/release-service@v0.0.0-20240507045911-a8558ef3422a/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/tdproto@v1.51.57/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/go-identity@v1.1.6/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/helm@v0.0.0-20221213002717-88a4a2c6e77d/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/prow@v0.0.0-20240503223140-c5e374dc7eb1/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/verrazzano-monitoring-operator@v0.0.30/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/go-base@v0.0.0-20231004214136-8be7e5c1972b/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/upjet@v1.3.0/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/governance-policy-propagator@v0.13.0/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/cluster-api-provider-azure@v1.14.3/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/unifi@v0.0.0-20230308161331-9b04946f5e93/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/newrelic-client-go@v1.1.0/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/v8@v8.1.0/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/types@v0.0.0-20240308101114-50a3a2f38dce/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/pe@v1.5.2/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/v2@v2.32.3/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/api@v0.0.0-20231107125330-c9a03957060c/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/Zoho@v1.1.4/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/newrelic-client-go@v1.1.0/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/v2@v2.10.9/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/go-client@v0.0.0-20240425220342-2317e10dfcf5/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/cass-operator@v1.20.0/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/v8@v8.1.0/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/libvirt-go-xml@v7.4.0+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/go-client@v0.210.0/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/verrazzano@v1.7.1/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/jx-api@v0.0.24/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/crowdsec@v1.6.1/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/v2@v2.51.0/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/v2@v2.24.0/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/verrazzano@v1.7.1/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/go@v0.10.32/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/release-service@v0.0.0-20240507143925-083712697924/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/v4@v4.2.0/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/fabric-operator@v1.0.4/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/apis@v0.10.8/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/api@v0.0.0-20240320170621-278e89a8c5fb/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/golinstor@v0.52.0/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/verrazzano@v1.7.1/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/community-operator@v0.0.6/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/api@v0.0.0-20231107125330-c9a03957060c/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/octokat@v0.0.0-20160826194511-076a32289ed5/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/gateway-api@v1.0.0/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/erda-infra@v1.0.9/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/govpp@v0.0.0-20230130211138-14ef5d20b1d0/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/bitclient@v0.0.0-20190425080230-bfee94efac35/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/govpp@v0.0.0-20240328101142-8a444680fbba/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/v4@v4.7.1/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/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/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/Sparta@v1.15.0/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/glamour@v0.7.0/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/guru@v0.0.0-20200207042420-2dabeb950d69/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/libvirt-go-xml@v7.4.0+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/gateway-api@v1.0.0/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/runner-go@v1.12.0/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/saml@v0.4.14/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/api@v0.0.0-20240427025202-5cbd3cbd9237/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/libvirt-go-xml@v7.4.0+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/jenkins-operator@v0.0.3/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/newrelic-client-go@v1.1.0/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/erda-infra@v1.0.9/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/twilio@v0.0.1/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/okex-api@v1.0.4/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/boleto-api@v0.0.0-20230620145841-3f9ec742599f/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/v6@v6.0.2/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/govpp@v0.0.0-20230130211138-14ef5d20b1d0/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/twilio-go@v1.20.1/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/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/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/go-algorand-sdk@v1.24.0/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/apis@v0.0.0-20220908090753-666f6cd72cfc/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/api@v0.0.0-20231218190037-9183ab93f33e/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/v6@v6.6.0/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/newrelic-client-go@v1.1.0/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/go-pagerduty@v1.8.0/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/ray-operator@v1.1.1/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/argocd-operator@v0.10.0/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/verrazzano@v1.7.1/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/v2@v2.2.2/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/gobgp@v2.0.0+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/client-go@v1.16.4/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/redis-operator@v1.2.4/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/component@v0.16.0-beta/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/compose-on-kubernetes@v0.5.0/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/kubeadm@v0.0.0-20191016155141-23a891785b60/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/newrelic-client-go@v1.1.0/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/kueue@v0.6.2/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/api@v1.12.0/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/cluster-api@v1.7.1/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/cluster-api-provider-aws@v1.5.5/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/api@v0.0.0-20240507183017-3110591cbafc/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/aries-framework-go@v0.3.2/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/v3@v3.5.0/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/multicloud-operators-foundation@v1.0.0/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/api@v0.0.0-20240507023248-73662d6db2c5/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/wtf@v0.43.0/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/gobgp@v2.0.0+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/go-client@v0.0.0-20240425220342-2317e10dfcf5/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/govpp@v0.0.0-20230130211138-14ef5d20b1d0/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/training-operator@v1.7.0/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/infoblox-go-client@v1.1.1/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/monitoring@v0.73.2/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/go-admin@v1.1.1/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/sdk@v0.11.0/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/hcp-sdk-go@v0.94.0/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/operator-tools@v0.28.10/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/twilio-go@v1.20.1/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/dgraph@v1.2.8/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/api@v0.0.0-20231107125330-c9a03957060c/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/build@v0.0.0-20240506185731-218518f32b70/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/iaas-api-go@v1.12.0/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/fabric-operator@v1.0.4/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/cluster-api-provider-aws@v1.5.5/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/go-netbox@v0.0.2/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/go-authcrunch@v1.1.4/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/operator-tools@v0.28.10/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/twilio-go@v1.20.1/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/newrelic-client-go@v1.1.0/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/kueue@v0.6.2/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/ari@v4.8.4+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/mc@v0.0.0-20240507152021-646712d5e5fb/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/kubevela@v1.9.11/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/go-shopify-graphql-model@v0.0.4/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/go-client@v0.0.0-20240425220342-2317e10dfcf5/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

@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).

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.