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

Consider deprecating omitzero in favor of a more general omitempty #120

Open
cespare opened this issue Mar 3, 2016 · 4 comments
Open

Consider deprecating omitzero in favor of a more general omitempty #120

cespare opened this issue Mar 3, 2016 · 4 comments
Labels

Comments

@cespare
Copy link
Collaborator

cespare commented Mar 3, 2016

It would be better if omitempty handled a variety of zero values -- including for numeric types -- as encoding/json does, rather than having a separate omitzero concept.

@bbuck
Copy link
Contributor

bbuck commented Mar 3, 2016

What if the zero value is acceptable but given a pointer nil means it should be left out.

@cespare
Copy link
Collaborator Author

cespare commented Mar 3, 2016

@bbuck I don't understand what you're saying about "zero value is acceptable".

I opened #124 to extend omitempty to handle nil values of pointer and interface type.

@bbuck
Copy link
Contributor

bbuck commented Mar 3, 2016

Must have misunderstood your original wording.

On Wednesday, March 2, 2016, Caleb Spare notifications@github.com wrote:

@bbuck https://github.com/bbuck I don't understand what you're saying
about "zero value is acceptable".

I opened #124 #124 to extend
omitempty to handle nil values of pointer and interface type.


Reply to this email directly or view it on GitHub
#120 (comment).

@arp242
Copy link
Collaborator

arp242 commented Jun 10, 2021

The problem with changing this now is that it's an incompatible change; what if people have omitempty on their existing structs but that have no effect? Silly thing to do, perhaps, but just changing the behaviour strikes me as having the potential to cause a lot of confusion and problems.

If this was written today: yeah, this would obviously be the correct way to do it. But now we're kind of stuck with it until we do a v2 (if ever).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants