What's the difference of these 2 ways of initializing golang's struct?

Viewed 45
type Foo struct{}
var a = &Foo{}
var b = new(Foo)

There's two way to initialize, one is using Foo{}, another is new(Foo), this one returns a pointer, so if I change Foo{} to &Foo{}, these two basically becomes the same, is there different between these two types of initialization?

0 Answers
Related