0
Q:

golang loop through array

arr := []int{1, 2, 3, 4, 5}
//using range 
for index, ele := range arr { // you can escape index by _ keyword
	fmt.Println(index, ele)
}
5
a := []string{"Foo", "Bar"}
for i, s := range a {
    fmt.Println(i, s)
}
3

New to Communities?

Join the community