// The new built-in function allocates memory. The first argument is a type,
// not a value, and the value returned is a pointer to a newly
// allocated zero value of that type.
func new(Type) *Type
new函数会分配内存,返回的值是一个指向该类型零值的地址
eg:
goku := new(Saiyan)
// 等效
goku := &Saiyan{}
用那种方式取决于你,但是你会发现,当需要去初始化 结构体 字段时,大多数人更喜欢使用后者,因为后者更易读:
goku := new(Saiyan)
goku.name = "goku"
goku.power = 9001
//对比
goku := &Saiyan {
name: "goku",
power: 9000,
}