It also ties in with the work I am doing this very minute.
I have a segmented, multi-layer message protocol that is processed in various ways, and the basic principle is sentinal magic bytes marking sections, that are consumed from the top and padded out to appear the same length when they are forwarded.
Currently it is using defined, static, structs, and chained methods to encode reading or writing.
Previously I had written encoders that work on the principle of slice of interfaces, in this case, slice of codec.Codec, which is a defined interface type for some unit of data and how to read and write it from disk/wire format to in-memory variables that are addressable.
The dilemma is one I am still not satisfied at all with the construction, I kinda feel like maybe I need to try a third way, that uses method pointers , that an interface type of variable follows it. This way the coding is self-describing.
I just am not sure which way to go with it. My intuition is that the Go implementation of UTF-8 variable length encoding is a model that will make it easier, I want it to be as simple as ReaderWriter types... aargh... well, anyhow, gonna start with reading some of the current Go codebase anyhow. There is several good prototypes for similar stream/object processing code in there.