zero value

The value Go gives a variable automatically when you declare it without one: 0 for numbers, "" for strings, false for booleans and nil for pointers, slices and maps.

In more detail

Because the zero value is always defined, a fresh struct is valid rather than full of random data. Good Go design makes the zero value mean the safe default. The catch is that you cannot tell a value that was never set from one deliberately set to zero; use a pointer field or an extra boolean when that difference matters.

Example

var l limits
fmt.Printf("%+v\n", l)  // {Retries:0 Timeout: Strict:false}

Related terms

Taught in

References