We've learned we can't add more elements to an array. That's a real problem for our program, because we don't know in advance how many pieces of data our file contains. But that's where Go slices come in. Slices are a collection type that can grow to hold additional items — just the thing to fix our current program! We'll also see how slices can provide an easier way for users to provide data to all your programs, and how they can help you write functions that are more convenient to call.
There actually is a Go data structure that we can add more values to — it's called a slice. Like arrays, slices are made up of multiple elements, all of the same type. Unlike arrays, functions are available for slices that allow us to add extra elements onto the end.
To declare a variable that holds a slice, you type an empty pair of square brackets, followed by the type of elements the slice will hold.
This is just like the syntax for declaring an array variable, except that you don't specify the size.
Declaring a slice variable doesn't automatically create a slice. For that, you can call the built-in make function. You pass make the type of the slice you want to ...