lop trhoug sliced string code example
Example 1: loop list golang
a := []string{"Foo", "Bar"}
for i, s := range a {
fmt.Println(i, s)
}
Example 2: golang iterate through slice
var slice = []string{"Apple", "Orange", "Kiwi"}
for index, sliceItem := range slice { // You can omit index or sliceItem with a _
fmt.Println("Index in slice:", index)
fmt.Println("Fruit:", sliceItem)
}