nil

The Go value meaning nothing or not set, which is the zero value for pointers, slices, maps, channels, functions, interfaces and errors.

In more detail

A nil error means success. Reading from a nil slice or nil map is safe, but writing to a nil map or following a nil pointer makes the program panic. Compare with nil, as in if value == nil, before using optional data.

Example

if value == nil {
	fmt.Println("unset")
}

Related terms

Taught in

References