msgpack icon indicating copy to clipboard operation
msgpack copied to clipboard

`omitempty` unexpectedly omits a member when the member is a struct with a non-zero unexported member

Open hajimehoshi opened this issue 1 year ago • 2 comments

Issue tracker is used for reporting bugs and discussing new features. Please use Discord or stackoverflow for supporting issues.

Here is the minimum test case: https://go.dev/play/p/3FvUksIAooa

Expected Behavior

Nothing is printed

Current Behavior

got: "", want: "str"

Possible Solution

omitempty should not ignore a struct value which is with a non-zero unexported member. This should be possible by comparing with a zero value.

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation

hajimehoshi avatar Feb 17 '25 08:02 hajimehoshi

Opened #387 for this.

alliasgher avatar Apr 13 '26 22:04 alliasgher

Hi @hajimehoshi, this repo has been unmaintained for ~3 years so this issue is unlikely to get addressed here.

We're maintaining a community fork at github.com/Basekick-Labs/msgpack (v6) as a drop-in replacement. The omitempty behavior around structs with non-zero unexported members is something we can prioritize in the fork — would you be interested in filing the issue there or contributing a fix? Happy to review PRs.

xe-nvdk avatar Apr 14 '26 13:04 xe-nvdk