Know Your Nil
In Golang,
nil
is an interesting value. You may be familiar with Go’s philosophy of making the “zero value” meaningful.Uninitialized variables and fields are set to the zero value. For example, if you have a uninitialized variable of an integer type, its value will always default to 0. An uninitialized string will be the empty string. Likewise, the zero value for a pointer is
nil
.
Source: Know Your Nil, an article by Jeremy Mikkola.