Go Slices

A slice is a window onto an underlying array and is the everyday sequence type in Go. []int{82, 91, 76} creates one, len reports its length, and append returns a slice with a value added at the end. You must assign the result, because append may allocate a new array.

Go
package main

import "fmt"

func main() {
  scores := []int{82, 91, 76}
  scores = append(scores, 95)
  fmt.Println(len(scores), scores[3])
  fmt.Println(scores[1:3])
}
Read the full lesson