Type system

Go assignability

Assignment is allowed under the language assignability rules: for example identical types, or identical underlying types with at least one not named and neither a type parameter, or a value implementing an interface. Representable untyped constants can also be assigned. Example output: '[1 2]'.

Formal Syntax & Structure

go syntaxgo
var x T = value

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  type Scores []int  var s Scores = []int{1, 2}  fmt.Println(s)}
Go Reference