Arrays & Slices in Go
From the Go cheat sheet ยท Data Types & Structures ยท verified Jul 2026
Arrays & Slices
Working with arrays and slices
go
// Arrays (fixed size)
var arr [5]int
arr[0] = 10
// Slices (dynamic)
slice := []int{1, 2, 3}
slice = append(slice, 4)
// Make slice
s := make([]int, 5, 10) // len=5, cap=10๐ Arrays have fixed size, slices are dynamic
๐ append() to add elements to slices
๐ฆ make() to create slices with capacity
โก Slices are references to underlying arrays
Continue with Go
Save the full cheat sheet or work through every related task.