package main import "fmt" type TestKey struct { i int s string } func ptr() (*int, *int) { i := 100 return &i, &i } func main() { var errNil error var mapNil map[int]string //mapNil[1] = "aa" m := make(map[int]string) m[1] = "bb" assert(errNil == nil) assert(mapNil == nil) assert(m != nil) ms := make(map[string]int) ms["aa"] = 1 assert(ms["aa"] == 1) mss := make(map[TestKey]int) mss[TestKey{1,"a"}] = 2 assert(mss[TestKey{1,"a"}] == 2) assert(mss[TestKey{1,"b"}] == 0) mi := make(map[interface{}]int) mi[1] = 1 mi["a"] = 2 assert(mi[1] == 1) assert(mi["a"] == 2) mi["a"] = mi[1] assert(mi["a"] == 1) mp := make(map[*int]int) k, q := ptr() r,_ := ptr() mp[k] = 8 assert(mp[q] == 8) assert(mp[r] == 0) assert(*k == *r) fmt.Println(k, q, r, *k, *q, *r) }