Conversation
cb99045 to
fb5051e
Compare
|
@liggitt Thanks for contributing this PR!
Moved discussion from issue #643 to this PR.
Sounds good! If cbor struct tag is specified for omitzero, then we can make it unconditional.
For json tag, let's constrain omitzero to go 1.24+ (when cbor struct tag isn't specified). The original rationale for supporting json tag is to provide consistent behavior. So when
Sounds good! |
|
All of that sounds good. Will ping here when I have unit test coverage completed and this is ready for review (probably later today or tomorrow) |
|
Ok, all pushed... tests went faster than I thought. I copied existing OmitEmpty tests as a starting point, then added a second commit with adjustments where omitzero differs from omitempty and some additional unit tests. Let me know how you would like that squashed. |
827ca06 to
cbc35b2
Compare
|
(pushed an update to fix linter suggestions in the unit test) |
Thanks again for opening this PR! No need to squash because there's only a few commits and they aren't noisy. I'll take a closer look tomorrow. BTW, I'm working on one more item for v2.8.0, so there's a chance I won't be able to release tag this week. |
Signed-off-by: Jordan Liggitt <liggitt@google.com>
Signed-off-by: Jordan Liggitt <liggitt@google.com>
Signed-off-by: Jordan Liggitt <liggitt@google.com>
fxamacker
left a comment
There was a problem hiding this comment.
Looks great! 👍 Thanks again for contributing this PR!
Before tagging a release, I usually need about a week after the last PR is merged to check for regressions, etc.
Also, there is an unrelated optimization I started looking into, but I'm not sure if it will be included in v2.8.0 (depends on schedule).
How soon do you need v2.8.0 tagged?
| testRoundTrip(t, []roundTripTest{{"default values", v, want}}, em, dm) | ||
| } | ||
|
|
||
| func TestIsZero(t *testing.T) { |
There was a problem hiding this comment.
Thanks for adding this test for expected behavior of IsZero() for different scenarios.
| The "omitzero" option omits zero values from encoding, matching | ||
| [stdlib encoding/json behavior](https://pkg.go.dev/encoding/json#Marshal). | ||
| When specified in the `cbor` tag, the option is always honored. | ||
| When specified in the `json` tag, the option is honored when building with Go 1.24+. | ||
|
|
I'm not in a rush, Kubernetes is in code freeze for the next few weeks, so kubernetes/kubernetes#130989 (which is what prompted me to pick this up) wouldn't merge until late April anyway. |
Description
PR Was Proposed and Welcomed in Currently Open Issue
Checklist (for code PR only, ignore for docs PR)
Last line of each commit message should be in this format:
Signed-off-by: Firstname Lastname firstname.lastname@example.com
(see next section).
Certify the Developer's Certificate of Origin 1.1
the Developer Certificate of Origin 1.1.