protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

string time and duration

Open baryluk opened this issue 3 years ago • 0 comments

I would like to say this:

message X {
   optional string foo = 1 [default = "2m", (gogoproto.strduration) = true];
}

in text proto, and binary representation it would be a string, but a struct in Go will be a time.Duration that properly calls time.ParseDuration / dur.String().

Similar for time.Time (with possibility to specify the format to use).

Yes, this is less efficient than WKT Duration and Timestamp, for transmit over network or storage, but if using protocol buffers for configuration maintained by humans, it is way easier. Also there is no way to provide default values for WKT Duration and Timestamp.

baryluk avatar May 12 '22 11:05 baryluk