Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Patch Available
-
Patch
Description
When an optional field has a default value, the field won't have a pointer type anymore but will still keep the `omitempty` tag.
For example the following thrift file:
struct Node {
1: optional bool is_live = false
}
Will be generated as:
type Node struct { IsLive bool `thrift:"is_live,1" db:"is_live" json:"is_live,omitempty"` }
If you create an instance of this struct and set the value to `false`:
node := Node{IsLive: false}
And then json.Marshal `node`, the output will be:
{}
Where it must be:
{is_live: false}
This happens because Go Marshal will ignore `zero values` if there is an `omitempty` tag attached to it.
Attachments
Issue Links
- links to