Type system

Go slice types

Describes a segment of an underlying array. Assignment copies the slice value, not necessarily its elements. append may allocate a different array; the returned slice must be used. Example output: '[7 2] [7 2]'.

Formal Syntax & Structure

go syntaxgo
[]T

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  a := []int{1, 2}  b := a  b[0] = 7  fmt.Println(a, b)}
Go Reference