range over array code example
Example 1: go loop through 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 range arrat
for i, num := range nums {
if num == 3 {
fmt.Println("index:", i)
}
}