Zest.

Go: Loop over slices and maps

A short, tested Go example for loop over slices and maps. Copy it and adjust the names and paths for your project.

Go
for i, v := range []string{"a", "b"} {
    fmt.Println(i, v)
}
for k, v := range map[string]int{"a": 1} {
    fmt.Println(k, v)
}

Find it in Zest

Search for “go loop over slices and maps” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Go examples

All Go examples