golang iterate over values in map code example
Example 1: go iterate over map
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])
}
Example 2: golang iterate through map
var m = map[string]string{}
m["key"] = "value"
m["someOtherKey"] = "someOtherValue"
for key, value := range m {
fmt.Println(fmt.Sprintf("%s : %s", key, value))
}