Module 02 Β· Collections β Lesson 1 of 3 Β· ~12 min
Slices
A list of walkers, not just one
So far you've held a single value in a variable β one name, one price. A real PawWalk backend deals in lists: every walker near you, every booking in a day, every GPS fix on a route. Go's everyday list type is the slice.
Go has two list-like types, and the difference matters:
- An array has a fixed length baked into its type:
[3]stringis exactly three strings, forever. You almost never write these. - A slice is a growable view over a run of values:
[]stringβ note the empty brackets. This is what you actually use, every day.
Coming from Swift, a Go slice is your
Array. The fixed[3]stringarray is the odd one out β reach for a slice unless you have a specific reason not to.