4

I think the Golang serialization API is utter garbage.
By convention it usually looks like this,

MarshalFormat() ([]byte,error)
UnmarshalFormat([]byte) error

This means that all serialization and deserialization is done on, heap allocated, in memory buffers ( technically also mmaped files, but thats not cross platform).
As the Go GC is ruthlessly optimized for minimum latency, this can potentially cause memory leaks in long running applications.

I think we need a new serialization API that looks more like

SerializeFormat(io.Writer) error
DeserializeFormat(io.Reader) error

Comments
  • 3
    Go has no generics support, so the API for serialziation/desrialze feels like it was "tacked" on with the approach of "we need this, so lets do something minimal" feel to it. The whole tags thing is really annoying.

    However - I'm pretty sure you can find a library for that.
  • 0
    Just serialize to YAML or JSON. There should be libs for (de)serializing that formats...
  • 1
    @Oktokolo
    golang has this in the base libraries.
    for xml, json, and yaml.
    All use the same pattern of Marshal/Unmarshal. Using byte arrays.
Add Comment