type M map[string]interface{}
var item M
fmt.Println(reflect.TypeOf(item))
returns main.M
.
How can I find underlying type of item as map[string]interface{}
.
type M map[string]interface{}
var item M
fmt.Println(reflect.TypeOf(item))
returns main.M
.
How can I find underlying type of item as map[string]interface{}
.
Yes, you can fetch the precise structure of the type, if that's what you mean with "root type":
var item M
t := reflect.TypeOf(item)
fmt.Println(t.Kind()) // map
fmt.Println(t.Key()) // string
fmt.Println(t.Elem()) // interface {}
From there you're free to display it as you want.