For a map m
in golang, we can get simply the key type using t.Key()
.
But I wonder how to get the map value type?
When the map is empty, we can not even use v.MapIndex
, any idea?
m := map[string]int{}
t := reflect.TypeOf(m)
v := reflect.ValueOf(m)
t.Key()
v.MapIndex()