Type system

Go zero values

An uninitialized variable receives the zero value of its type, recursively for arrays and structs. Numeric zero, false, empty string and nil are different zero values; nil does not apply to every type. Example output: '0 false "" true'.

Formal Syntax & Structure

go syntaxgo
var x T

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  var n int  var b bool  var s string  var p *int  fmt.Printf("%d %t %q %t\n", n, b, s, p == nil)}
Go Reference