In Go (golang), how to iterate two arrays, slices, or maps using one `range`
You cannot, but if they are the same length you can use the index from range. package main import ( “fmt” ) func main() { r1 := []int{1, 2, 3} r2 := []int{11, 21, 31} if len(r1) == len(r2) { for i := range r1 { fmt.Println(r1[i]) fmt.Println(r2[i]) } } } It returns 1 11 …