|
|
|
|
|
by hnlmorg
26 days ago
|
|
This isn’t a type system problem. It’s a data origin problem. Ie it could be any random JSON blob a user entered. The compiler doesn’t know this ahead of time. If you wanted type safety with JSON in Go then don’t use the marshal interface. Period. |
|
And even for unmarshalling you could get a compile time error if you try to unmarshall to a type that doesn't support it.