Is there a way to get a list of all the keys in a Go language map? The number of elements is given by len()
, but if I have a map like:
m := map
https://play.golang.org/p/JGZ7mN0-U-
for k, v := range m {
fmt.Printf("key[%s] value[%s]\n", k, v)
}
or
for k := range m {
fmt.Printf("key[%s] value[%s]\n", k, m[k])
}
Go language specs for for statements specifies that the first value is the key, the second variable is the value, but doesn't have to be present.