关于map的v值是结构体的一些疑问

wangyanlb · · 2982 次点击
type Person struct { Likes []string } p := new(Person) p.Likes = append(p.Likes, "movie") logger.Debug("%v", p.Likes) result: [movie]
#1
更多评论
type Person struct { Likes []string } p := Person{make([]string, 1)} p.Likes = append(p.Likes, "movie") logger.Debug("%v", p.Likes) p = Person{Likes: make([]string, 1)} p.Likes = append(p.Likes, "movie") logger.Debug("%v", p.Likes)
#2
单纯结构体没有问题,如果 把结构体作为一个 map类型的v值,怎么赋值呢
#3