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

omitempty for tags that marshal into zero val but should be nil #687

Merged

Conversation

gregbarasch
Copy link
Contributor

@gregbarasch gregbarasch commented Feb 25, 2025

💸 TL;DR

By default, if we marshal a map or slice from nil into yaml, then back into the map/slice, the value will not be the same!
Without omitempty, we marshal nil into the emptyval, then emptyval as is back into the struct. It is not a known guarantee for users that nil == empty.

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo

@gregbarasch gregbarasch marked this pull request as ready for review February 25, 2025 17:11
@gregbarasch gregbarasch requested a review from a team as a code owner February 25, 2025 17:11
@gregbarasch gregbarasch requested review from fishy, kylelemons and konradreiche and removed request for a team February 25, 2025 17:11
@fishy fishy merged commit 123e3d5 into reddit:master Feb 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants