Slice
Slices in Go: Grow Big or Go Home
Slices are way more flexible than arrays since they’re basically a layer on top of an array. They can resize dynamically, and you can use append()
to add more elements.
How Go Arrays Work and Get Tricky with For-Range
As always, we’ll start with the basics and then dig a bit deeper. Don’t worry, Go arrays get pretty interesting when you look at them from different angles. Arrays in Go are a lot like those in other programming languages. They’ve got a fixed size and store elements of the same type in contiguous memory locations.