I would like to de/serialize (go both ways, as it were) Go structs from/into various forms such as JSON, YAML, BSON, and so forth. This is pretty simple until one considers deserializing interfaces.
Solutions to this are available on the web, but there isn’t a simple framework to deal with the necessary steps. I’ve been wrestling with this problem for a while as I’d really like it to just work and it always seems to require a lot of application-specific (or perhaps I should say interface-specific) coding.
My current solution is in
github.com/madkins23/go-serial. It sort of does what I want but trying to use it in an existing code body wasn’t as simple as I’d hoped. I find myself wondering if it’s worth putting more time into it.
Mostly I find myself wondering if I’m not trying to do something anti-Go. Like when I really, really want dynamic lookup of “subclass” methods because I’m thinking of my data as coming in classes instead of composited structs (which would most likely solve the current problem…I believe I have code for that solution in Java in some partially completed personal project). Usually I have to reset my expectations and think like a Gopher before things get clear and simple and I think perhaps this may be true here.
I wouldn’t mind some general discussion. I’m not trying to build some uber-framework that will solve everyone’s problems. This is just something that has fallen out of my own personal (and admittedly silly) projects. I’m more interested in how I’ve really misunderstood the language and I should just do this or that and all will be well.
Since I’m hoping to keep comments and discussion to one forum (this one) I’ve turned off commentary and discussion in github. And issues. Really not ready for issues.