Okay Go, why was this omitted?

Sean Hoffman
1 min readNov 23, 2022

When checking for the existence of a particular key in Go, the idiomatic way of doing things is this:

salary := make(map[string]uint)

_, ok := salary["Roger Goodell"]

if !ok {
// value wasn't found
salary["Roger Goodell"] = 68000000
} else {
fmt.Println("Roger Goodell is not hurting for cash.")

Simple right? Well yes, but also horribly inconvenient. I don’t want to define an in-scope variable to determine if a key exists in the map; sometimes I might want to check and quickly branch off that logic.

Sean Hoffman

Software Developer (C++, C#, Go, others), Husband, Father