make(T, ...) — allocates and initializes slices, maps, and channels. new(T) — allocates zeroed storage for any type, returns a pointer.
For slices, make sets up the backing array with the specified length and capacity. For maps, it creates the hash table. For channels, it allocates the send/receive buffer.
1s := make([]int, 0, 1000) // preallocate for 1000 items2m := make(map[string]int, 100) // hint for ~100 entries3ch := make(chan int, 50) // buffered channel
new allocates sizeof(T) bytes, zeroes them, returns *T. For simple types (int, bool) this is fine. For slices/maps/channels, the zero value is nil — unusable without make.
1p := new(int) // *int → 0, usable2s := new([]int) // *[]int → nil, NOT usable3// Must: *s = make([]int, 0)
When to use:
&T{...} for structs.Common mistakes:
new([]int) → nil slice, needs make.make([]int, 10) → len=10 (zeros), not empty with cap=10.make on non-slice/map/channel — compile error.