I have an enum defined as
type MyEnum int
const(
FirstEnum MyEnum = iota
)
"Key": "FirstEnum"
var data map[string]interface{}
err := json.Unmarshal([]byte(json), &data)
x := data["key"].(MyEnum)
When I run this, however, I get the error:
panic: interface conversion: interface {} is string, not ps.Protocol [recovered]
panic: interface conversion: interface {} is string, not ps.Protocol
Is there a way to get this to work like a normal conversion of a string representation of a enum to enum type in Go?