Go-new和make

new返回指向struct的指针,new仅分配内存,而不对对象的值进行初始化

make返回到strcut的对象,而不是指针,只能创建map,slice,channel对象

make([]string, 5, 10)

new([]string)

http://www.sharejs.com/codes/go/5610

http://docs.studygolang.com/doc/effective_go.html#allocation_make

http://docs.studygolang.com/ref/spec

原文地址:https://www.cnblogs.com/helww/p/4101408.html