Tech Note
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Lookups On A Nil Map

You can do lookups on a nil map:

var xs map[string]string = nil
x, hasX := xs["hello"]

The result will simply be the zero value of the particular type. In this case x will be the empty string.