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

wangyanlb · · 2961 次点击
http://studygolang.com/articles/4477 这篇文章应该会帮助你
#7
更多评论
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