这样写好?:
p := []interface{}{"abc", map[string]string{"key1":"val1","key2":"val2"}}
str, _ := p[1].(map[string]string)
fmt.Println(str["key1"]);
还是这样写?:
p := []interface{}{"abc", &map[string]string{"key1":"val1","key2":"val2"}}
str, _ := p[1].(*map[string]string)
fmt.Println((*str)["key1"]);
我明白了
Maps are reference types, so they are allways passed by reference. You don't need a pointer.
#2