protobuf
protobuf copied to clipboard
Surprising marshaling behavior when combining stdtime and nullable
When using stdtime=true and nullable=false for google.protobuf.Timestamp, the zero value time.Time ends up being marshaled with the seconds field set to -62135596800. This happens because Go's time.Time zero value is January 1, year 1, 00:00:00 UTC, while Timestamp uses the Unix epoch, so ~1970 year difference. I found this behavior a bit surprising as I would have expected the zero value to be omitted from the resulting message altogether.
Making this change in timestamp_gogo.go doesn't seem difficult, but I'm wondering if there are any reasons why this wasn't done in the first place or if there are any backward-compatibility issues to be considered at this point?