See this playground example.
Docs says:
If omitempty is applied to a struct and all the children of the struct are empty, then on marshalling it will be omitted from the encoded json.
Using omitempty on a time.Time field makes Marshal function always ignore the field.
I suspect this is because time.Time has no exported children and relies on the MarshalJSON function for serialization.
See this playground example.
Docs says:
Using
omitemptyon atime.Timefield makesMarshalfunction always ignore the field.I suspect this is because
time.Timehas no exported children and relies on theMarshalJSONfunction for serialization.