golang new和make的区别

2019-04-24
阅读 4 分钟
14.8k
Go语言中new和make都是用来内存分配的原语(allocation primitives)。简单的说,new只分配内存,make用于slice,map,和channel的初始化。