7. Arrays and Slices — A Book of Go

Louis Petrik
2 min readMay 15, 2024
Source: the author

Arrays and slices are ways to create “lists” of data in Go. The key difference between both is that arrays are of fixed size, while slices can grow and shrink in size.

Arrays

The type [n]Tis an array of nvalues of type T.

var a [10]int

Is an empty array. Values can be accessed by: a[0] = 10

--

--