zabbix-tools / go-zabbix

Go bindings for the Zabbix API
GNU General Public License v2.0
108 stars 70 forks source link

Fix json "omit empty" caveat #26

Closed thiagodamas closed 2 years ago

thiagodamas commented 5 years ago

When using "omitempty" inside struct definition, and the value is "0" (zero), there are some caveats: https://stackoverflow.com/questions/38486564/unmarshal-marshal-json-with-int-set-to-0-does-not-seem-to-work

cavaliercoder commented 5 years ago

Thanks for this! I'm not sure the default struct tag will have any effect here? I believe we need the go-defaults package for that to work? Interesting idea!

Maybe it does make sense to remove the omitempty, but I think the onus is still on the caller to explicitly set the History data type they are querying, rather than defaulting to ints.

arkady-bagdasarov commented 4 years ago

How we can you 0 value for History field?!