Re: [go-nuts] encoding.BinaryMarshaler interface

2017-01-12 Thread hanisch
Thanks so much for your reply! Yes, making Foo an io.WriterTo is exactly what I was looking for! I'll have Foo implement both WriteTo and MarshalBinary methods (with the latter making a new backing array with each call, and possibly using a sync.Pool later on, after benchmarking actual use cas

Re: [go-nuts] encoding.BinaryMarshaler interface

2017-01-11 Thread Matt Harden
I would start with the naive implementation first, and only make it fancier (and more complicated) if that turns out not to be fast enough. Go's GC is pretty good already and getting better. You must not change the data in the returned slice after returning it, unless you somehow know that the cal