In Go, an array is a numbered sequence of elements of a specific length. In typical Go code, slices are much more common; arrays are useful in some special scenarios. |
|
![]() ![]()
|
|
|
|
|
|
Here we create an array |
|
We can set a value at an index using the
|
|
The builtin |
|
Use this syntax to declare and initialize an array in one line. |
|
Array types are one-dimensional, but you can compose types to build multi-dimensional data structures. |
|
Note that arrays appear in the form |
|
Next example: Slices.