1.//对map中的struct赋值
type person struct { id int name string } func main() { persons := make(map[int]person) persons[0] = person{1,"a"} log.Println(persons[0]) v,ok := persons[0] if ok { v.id = 0 persons[0] = v } log.Println(persons) persons1 := make(map[int]*person) persons1[0] = &person{1,"a"} log.Println(persons1[0],",persons1) _,ok = persons1[0] if ok { var p *person p = persons1[0] p.id = 5 (*persons1[0]).id = 10 } log.Println(persons1,persons1[0]) }