Accept omitzero as an alias of omitempty - #404
Open
AshSgDe29071999 wants to merge 1 commit into
Open
AshSgDe29071999 wants to merge 1 commit into
AshSgDe29071999 wants to merge 1 commit into
Conversation
Go 1.24's encoding/json flag omitzero panics getStructInfo, which only knows omitempty/flow/inline. yaml's omitempty already drops zero values, so treat omitzero as the same so structs that share tags with json work. Related: go-yaml/yaml#1068 (archived v3 tree).
Contributor
|
This would require further checks. encoding/json omitzero is not omitempty yaml/go-yaml omitempty might behave the same way for struct (I have to check) that encoding/json handles omitzero But then I'm unsure yaml/go-yaml should handle omitzero the same way for non-struct So it might not be about aliasing. Maybe it's more about handing omitzero the same way that omitempty for struct only. |
ingydotnet
self-requested a review
August 31, 2026 16:59
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go 1.24 added
omitzeroforencoding/json.getStructInfoonly knowsomitempty,flow, andinline, so a struct that shares tags with json panics inmappingStruct:This library's
omitemptyalready drops zero values (including structs), so treatomitzeroas the same flag.This is the same failure as the archived v3 tree (go-yaml/yaml#1068).
Maintainers' edits to the PR description 👇
Somehow related to #235