Skip to content

Instantly share code, notes, and snippets.

@kjk
Created November 5, 2019 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjk/f807e821184ffe8409d40f55de373044 to your computer and use it in GitHub Desktop.
Save kjk/f807e821184ffe8409d40f55de373044 to your computer and use it in GitHub Desktop.
for loop over a slice with range
// :collection Essential Go
package main
import "fmt"
func main() {
// :show start
a := []int{1, 3, 5}
for idx, value := range a {
fmt.Printf("idx: %d, value: %d\n", idx, value)
}
// :show end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment