I ran into an issue that was annoying to track down and I'm not sure I entirely get it. I was using jsonenums as part of a nested struct slice, and explicitly setting the json field name & setting the omitifempty flag. My observation was that if I built an instance of that struct explicitly setting the value to be iota 0 as documented in the shirtsize example project, the value during encoding would be removed entirely. If I removed the omitifempty flag, the proper value would show up. Likewise I could also work around it by just adding 1 to the iota const. It may be worth further investigation and/or a simple documentation update to warn people about this.
I was able to track it as far as here in the golang encode library. My gut is telling me somewhere there is a confusion between an iota value of 0 and a nil which is what I expect omitifempty to apply to.
I ran into an issue that was annoying to track down and I'm not sure I entirely get it. I was using jsonenums as part of a nested struct slice, and explicitly setting the json field name & setting the omitifempty flag. My observation was that if I built an instance of that struct explicitly setting the value to be iota 0 as documented in the shirtsize example project, the value during encoding would be removed entirely. If I removed the omitifempty flag, the proper value would show up. Likewise I could also work around it by just adding 1 to the iota const. It may be worth further investigation and/or a simple documentation update to warn people about this.
I was able to track it as far as here in the golang encode library. My gut is telling me somewhere there is a confusion between an iota value of 0 and a nil which is what I expect omitifempty to apply to.