4 ms·
Simple: new() is for memory allocation, make() is for the more complex initialization of reference types. http://research.swtch.com/godata http://research.swtch
by mseepgood 14y ago
Simple: new() is for memory allocation, make() is for the more complex initialization of reference types.
http://research.swtch.com/godata http://research.swtch.com/godata
http://golang.org/doc/go_faq.html#references http://golang.org/doc/go_faq.html#references
Why can't you add methods to types outside of your package boundaries? Because Go aims for clean, comprehensible, robust boundaries between components: http://talks.golang.org/2012/splash.article http://talks.golang.org/2012/splash.article