golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.64k stars 1.58k forks source link

encoding/prototext: Handle well-known Timestamp message as string #1582

Open calmh opened 6 months ago

calmh commented 6 months ago

Currently, there is no special handling for timestamps. A timestamp field in a message is marshalled as seconds and nanoseconds:

created_at {
  seconds: 1703153845
  nanos: 392723000
}

For human consumption I think it would be nicer if timestamps were represented as strings:

created_at: "2023-12-21T10:17:25.392723Z"

Presumably, unmarshalling could support both variants.

cybrcodr commented 6 months ago

The prototext package follows the protocol buffer Text Format Language Specification. And that specification does not provide any special handling for well-known types.