How do i convert from map[string] MyStruct to map[string] MyInterface, when MyStruct implements MyInterface.
type MyInterface interface {
Say() string
}
var MyInterfaceMap map[string] MyInterface
type MyStruct struct{
Message string
}
func (myStruct *MyStruct) Say() string{
return myStruct.Message
}
func Init() {
data := []byte(`{"greet":{"Message":"Hello"}}`)
myStructMap := make(map[string] MyStruct )
_ = json.Unmarshal( data, &myStructMap)
MyInterfaceMap = myStructMap
}