slice

A flexible, growable view over a list of values of one type, written like []string, and Go's everyday list.

In more detail

append adds items, growing the storage underneath when needed, and len gives the count. items[1] reads one element and items[:2] makes a smaller view of the first two. A nil slice is empty and safe to append to, so you rarely need to create one first.

Example

items := []string{"api", "worker"}

Related terms

Taught in

References