The built-in function len returns the number of elements in a map
len
map
m := map[string]int{} len(m) // 0 m["foo"] = 1 len(m) // 1
If a variable points to a nil map, then len returns 0.
nil
var m map[string]int len(m) // 0