Arrays
An array is a list with a fixed size.
Every item has the same type.
Think of egg cartons. A carton for 6 eggs cannot suddenly hold 12.
The size is part of the type, so [3]int and [4]int are different.
Declaring arrays
Put the size in brackets.
Indexes start at 0.
Empty slots get the starter value for that type.
Array literals
You can fill values right away in curly braces.
Use [...] to let Go count the length from the values you list.
Reading and writing slots
Use the index in brackets to read a slot.
Use the same form to put a new value in a slot.
Arrays are values
If you copy an array into another variable, you get a full copy.
Changing one does not change the other.
They are two separate cartons.
When arrays make sense
Use arrays when you know the size and it will not change.
For lists that grow, use slices next.
Most day-to-day Go code uses slices, not arrays. Arrays are still the fixed base.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.