juniorGolang

What is the difference between `new` and `make`?

Updated Apr 28, 2026

Short answer

new allocates zeroed memory and returns a pointer. make initializes slices, maps, and channels, returning the initialized value.

Deep explanation

new(T) allocates memory for a new item of type T, zeros it, and returns a pointer *T. It does not initialize the internal structures. make(T, args) creates slices, maps, and channels only, and it initializes their internal data structures (like the hash table for a map), returning the value T (not a pointer).

Real-world example

Using make to pre-allocate a slice with a specific capacity make([]int, 0, 100) to optimize performance when appending data in a loop.

Common mistakes

  • Using `new` on a map or channel and attempting to use it immediately, which results in a nil pointer dereference/panic.

Follow-up questions

  • Can you use `make` for structs?

More Golang interview questions

View all →