Creating a slice with make
The built-in make function lets you create a slice with a specific length and capacity — this is how most dynamically-sized slices get created.
make allocates a zeroed array and returns a slice pointing to it:
a := make([]int, 5) // len(a)=5
Pass a third argument to set the capacity separately from the length:
b := make([]int, 0, 5) // len(b)=0, cap(b)=5
b = b[:cap(b)] // len(b)=5, cap(b)=5
b = b[1:] // len(b)=4, cap(b)=4
Try it: Experiment with different length/capacity combinations and watch printSlice show how they change.