make(T, args) — initializes slices, maps, and channels, returning a ready-to-use value. new(T) — allocates zeroed storage for any type, returning a *T pointer.
For slices, make accepts length and optional capacity arguments, allocating the backing array. For maps and channels, it initializes internal hash tables or ring buffers.
1s := make([]int, 5) // [0 0 0 0 0], len=5, cap=52s2 := make([]int, 0, 100) // [], len=0, cap=1003m := make(map[string]int) // ready to use4ch := make(chan int, 1) // buffered channel
new allocates memory and fills it with the zero value of T. It does NOT call any constructor — the returned pointer points to a zeroed value. For slices/maps/channels, the zero value is nil.
1p := new(int) // *int → 02*p = 4234q := new([]int) // *[]int → nil5*q = make([]int, 0, 10) // still need make
When to use:
&T{...} literal syntax instead for structs.Common mistakes:
new([]int) and assuming the result is usable — it is a nil slice.make([]int, 10) (fills with zeros, len=10) with make([]int, 0, 10).make for non-slice/map/channel types — compilation error.