Hello Gophers,I have bunch of questions trying to use Protobuf for the first time with Go and I wish you guys can help me with most of it.I. Type conversion :
- How would you convert a [][]string to protobuf ? I've read on a StackOverflow thread to use a repeated string_slice, the later being a message composed of a repeated string. The problem with that solution is that the conversion when generated to Go files isn't quite the same.
- How would you convert a map[string]interface{} to protobuf ? The best solution I've come up with is using Any but I'm wondering if actually using a Struct isn't better. I tried to do a map<string, Any> but this doesn't quite translate neither.
- Same question actually goes for []map[string]interface{} ? Since you can't do repeated map<string, Any>.
- Finally, how would you serialize some interface{} in an Any type since you have to provide a []byte. ==> json.Marshal ? That wouldn't make much sense to use that serializer to use Protobuf after.
II. Protobuf usage :
- When I use Any, I get this import in my Go generated file : import google_protobuf "google/protobuf/any" which obviously is not found when compiling the Go. Any way to prevent that at protoc time ?
- Do you recommend using only your Protobuf structure in all messages ? For example, if I had a previous structure used in my code everywhere, should I rather convert it to use the generated Go structure or try to build a converter between old and new structure ?