Does a foreach loop exist in Go? How to iterate a slice?
Hi everyone! I've just started learning Go after Python and JavaScript, and I'm confused about one thing. In Python I'm used to writing `for item in my_list:`, and in JS — `myArray.forEach(item => ...)`. It's very convenient when you need to iterate over all elements of a collection.
In Go I only see the classic `for i := 0; i < len(slice); i++` loop, which looks cumbersome. I tried writing something like:
```go
package main
import "fmt"
func main() {
fruits := []string{"apple", "banana", "cherry"}
// Here I'm stuck — how to do foreach?
// I tried this, but it doesn't work:
// for fruit := range fruits {
// fmt.Println(fruit)
// }
}
```
When I run this code, it prints indices (0, 1, 2) instead of the actual values. I expected to see "apple", "banana", "cherry".