tinylib / msgp

A Go code generator for MessagePack / msgpack.org[Go]
MIT License
1.79k stars 190 forks source link

Support time duration #311

Closed arl closed 2 years ago

arl commented 2 years ago

Hi, we've been needing to add msgpack to a large codebase using many POD structures, some of them had time.Duration fields.

We haven't found a way to directly use time.Duration and it seemed like a good addition. We're just sending the int64 value and converting at the edge, we don't decode the string version (eg 3m30s).

Is this something you'd be interested in being merged upstream? If so, let me know what/if should I add anything to the current pull-request.

By the way, thanks for a very well-thought, easy to use and performant library.

klauspost commented 2 years ago

I honestly can't think of any reasons not to add this.

Representing a time.Duration as an int64 of course looses the type but makes it much cleaner than an extension (and more compact as a bonus).

philhofer commented 2 years ago

Thanks!