See the last section of this article where it talks about generics -
https://blog.gopheracademy.com/advent-2016/advanced-encoding-decoding/
It isn't exactly what you are doing but the same idea should work in your use
case. The encoding/decoding code becomes longer but it makes using the data
s
If I need to read some json which could be
{
"tag": "number",
"value": 1
}
or
{
"tag": "object",
"value": {
"a": 1,
"b": 2
}
}
what is the best way to unmarshall it?
I could unmarshall into
struct {
Tag string
Val interface{}
}
But once I have read the d