Go panics when writing to a nil map

Note: I originally posted this on Medium. I am learning Go and I ran into the following error when trying to convert a string to a map: package main const alphabetStr string = "abcdefghijklmnopqrstuvwxyz" func main() { var alphabetMap map[string]bool for _, r := range alphabetStr { c := string(r) alphabetMap[c] = true } } Running this program throws the following error: panic: assignment to entry in nil map I figured this had to do something with the fact that alphabetMap was not declared to be a certain size.