Golang反映,如何获取地图值类型?

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()

Elem() of a map type will give you the element's type:

var m map[string]int
fmt.Println(reflect.TypeOf(m).Elem())
// output: int