encoding icon indicating copy to clipboard operation
encoding copied to clipboard

handling of time.Duration deviates from stdlib

Open dominicbarnes opened this issue 4 years ago • 0 comments

This library currently encodes and decodes time.Duration values as strings. This deviates from the stdlib, as the type time.Duration does not implement json.Marshaller and is treated as an int64 instead.

Since this library implements this custom logic for both encode and decode, using it on both sides of an exchange of data is no problem. However, when interacting with other decoders (including the stdlib, but also extends to other languages/tools) the difference can be breaking.

My understanding is that this particular behavior is relied on heavily within Segment, so simply changing it to adhere strictly to the stdlib will be breaking for us.

There is currently no way to turn this functionality off, so in the short-term we should expose a config flag to support this. Over the long-term though, matching the stdlib should be the default and the flag should instead enable this additional functionality.

dominicbarnes avatar May 27 '21 21:05 dominicbarnes