mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
8 lines
452 B
Markdown
8 lines
452 B
Markdown
|
|
When marshaling, a struct field with the new `omitzero` option in the struct field
|
||
|
|
tag will be omitted if its value is zero. If the field type has an `IsZero() bool`
|
||
|
|
method, that will be used to determine whether the value is zero. Otherwise, the
|
||
|
|
value is zero if it is [the zero value for its type](/ref/spec#The_zero_value).
|
||
|
|
|
||
|
|
If both `omitempty` and `omitzero` are specified, the field will be omitted if the
|
||
|
|
value is either empty or zero (or both).
|