Default zero values for all Go types

yourbasic.org/golang

Variables declared without an initial value are set to their zero values:

The initialization is done recursively.

type T struct {
    n int
    f float64
    next *T
}
fmt.Println([2]T{}) // [{0 0 <nil>} {0 0 <nil>}]

Share this page: