Hello all, I wrote a package that parses a language (bash) and constructs an AST. I would like to make it easier for other tools to use it, even outside of Go.
I'm aware that Go can be built as a shared library, but I'd like to go a simpler route especially for scripting languages. What encoding would suit best? I initially thought something like encoding/json, which would work fairly well to give data. But it starts to break with interfaces. For example: https://godoc.org/github.com/mvdan/sh/syntax#Stmt Once in json, the type information is lost and needs to be inferred. This could still be okay. But the problem is unmarshalling back, e.g. if the script modifies the AST and Go wishes to read it back to, for example, write the modified version into a formatted .sh file. I'm expecting this to not work at all, since the best it could do is map[string]interface{}. What encoding/format should I use? I'm aware of "typed" wire encodings like grpc's, but that's probably too overkill for this. I was thinking of switching back and forth between the true types and map[string]interface{} manually via reflect, adding "Type" fields to each interface value. But as you can imagine, that's a lot of boilerplate. And I'm fairly sure there has to be something for this. -- Daniel Martí - mv...@mvdan.cc - https://mvdan.cc/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.