I found two questions and read them:
But I still don't understand why I tried mapping an Object that got error:
./aaa.go:21: m.Action undefined (type interface {} is interface with no methods)
type MyStruct struct {
}
func (a *MyStruct) Action() {
fmt.Println("Hello")
}
func main() {
var Mstruct map[string]interface{}
Mstruct = make(map[string]interface{}, 100)
Mstruct["MyStruct"] = &MyStruct{}
m := Mstruct["MyStruct"]
fmt.Println(reflect.TypeOf(m)) // *main.MyStruct
m.Action()
}
This always works in dynamic language, so I miss something in static language.