feat: support for omitzero added in Go 1.24#512
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #512 +/- ##
=======================================
Coverage ? 41.44%
=======================================
Files ? 67
Lines ? 5801
Branches ? 0
=======================================
Hits ? 2404
Misses ? 3118
Partials ? 279 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b37d280 to
2acdf26
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds a PreferOmitzero boolean to generator config and updates the schema generator to emit Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/generator/config.go`:
- Around line 38-39: Fix the typo in the comment for the PreferOmitzero field:
change the phrase "will use omit omitzero" to "will use omitzero" in the comment
above the PreferOmitzero bool declaration so the comment reads that
PreferOmitzero will use omitzero instead of omitempty (requires Go 1.24+);
update the comment attached to PreferOmitzero accordingly.
🧹 Nitpick comments (2)
tests/data/preferOmitzero/preferOmitzero.go (2)
46-66: Note: Unusedrawvariable in generated code.The
rawmap is unmarshalled but never used (lines 47-50). This appears to be a pre-existing pattern in the generator templates, likely used for other validation scenarios. Consider cleaning up the generator template to omit this when not needed, but this is outside the scope of this PR.
68-89: Same observation for UnmarshalYAML.The
rawmap decoding (lines 70-73) follows the same unused pattern asUnmarshalJSON. Same suggestion applies regarding generator template cleanup as a future improvement.
2acdf26 to
b201caf
Compare
b201caf to
f15ccbd
Compare
This PR adds optional support for emitting
omitzerotags (instead ofomitempty).omitzerois a new feature that was added in Go 1.24 for json marshaling,fixes #471
Summary by CodeRabbit