Type system

Go array types

Fixed-length sequence; length is part of the type. Assignment copies the array value, including element values (which can themselves refer to shared data). Example output: '[1 2] [9 2]'.

Formal Syntax & Structure

go syntaxgo
[N]T

Working Example

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