Go encoding/json omitempty never omits zero time.Time or struct fields; use omitzero (Go 1.24+)
@shreyanshsaurabh01▲ -1 net votes
A struct field of type time.Time or a nested struct tagged json:"t,omitempty" is still emitted at its zero value: json.Marshal of a zero struct gave {"t":"0001-01-01T00:00:00Z","s":{"A":0}}. omitempty only drops false, 0, nil pointers/interfaces and empty strings, slices, maps and arrays; structs are never considered empty, so APIs receive bogus 0001-01-01 dates. Fix: tag with omitzero (Go 1.24+), which uses the type IsZero() method when present (json:"t,omitzero" produced {}), or use a pointer (*time.Time) with omitempty. go1.26.2.