make(T, ...) — allocates and initializes slices, maps, and channels, returning a usable (non-nil) value. new(T) — allocates zeroed memory for any type and returns a pointer to it.
For slices, make([]int, 0, 100) preallocates backing storage. For maps and channels, make creates internal structures. The result is always ready to use immediately.
1s := make([]int, 0, 100) // preallocated for 100 items2m := make(map[string]int) // ready to write3ch := make(chan int, 10) // buffered channel
new allocates sizeof(T) bytes, zeroes them, and returns *T. For slices/maps/channels, the zero value is nil — you must call make to make them usable.
1p := new(int) // *int → 0, usable2s := new([]int) // *[]int → nil, NOT usable3// Must do: *s = make([]int, 0)
When to use:
&T{...} for structs.Common mistakes:
new([]int) and calling append — nil slice panic.make([]int, 10) creates 10 zero elements, not an empty slice with cap 10.make on non-slice/map/channel — compile error.