Skip to content

Arrays

Beginner · Collections & Loops

An array has a fixed length that is part of its type ([3]int[4]int). Arrays are values: assigning or passing one copies all elements. Indexing is zero-based. In practice slices are used far more often than arrays.

Arrays are zero-indexed — fix the out-of-range access.

Show hint
Arrays use zero-based indexing.

Source

An array can’t mix types; every element shares one type.

Show hint
Unlike languages like Python or Ruby, Go does not allow arrays with mixed data types.

Source