I never use new(). It gives a way to allocate, that I would prefer to avoid in favor of declaring zero-value explicitly. Maybe I am missing the point of new().
[1] - https://pkg.go.dev/sync/atomic#Int32 [2] - https://pkg.go.dev/go.uber.org/atomic
p := new(int)
since you can't say p := &int{} var (
p1 = new(int)
p2 = new(*int)
p3 = new(**int)
p4 = new(complex64)
p5 = new(complex128)
)
I feel like you must be joking. Should we say var (
c complex128
p = &c
)
every time?