go-driver icon indicating copy to clipboard operation
go-driver copied to clipboard

omitempty and integer

Open Fruchtgummi opened this issue 5 years ago • 3 comments

The integer 0 is omitempty

Available float64 json:"available"``

if I set not the value then saved arango the value 0. I must ever set all INT values ala patch though I use updatedocument.

Okay, so we'll just use omitempty!

Available float64 json:"available, omitempty"``

ok, this goes so far, but if I set the value from INT to 0, then omnitempty has an effect.

0 is not omitempty

Fruchtgummi avatar Aug 03 '20 09:08 Fruchtgummi

Hello!

If you use Available *float64 then it will work for any type. For most cases there is no "empty" value discovery in json marshal.

Best Regards, Adam.

ajanikow avatar Aug 07 '20 14:08 ajanikow

If i make math with pointer, then he returns the following error to me: "(operator + not defined on pointer)"

Fruchtgummi avatar Aug 11 '20 13:08 Fruchtgummi

You'll need to dereference the pointer after checking that it's not nil.

irridia avatar Oct 01 '20 04:10 irridia