A Tour of Go Range continued

时间:2023-01-02 22:56:36

You can skip the index or value by assigning to _.

If you only want the index, drop the ", value" entirely.

package main 

import "fmt"

func main() {
pow := make([]int, )
for i := range pow {
pow[i] = i << uint(i)
}
for _, value := range pow {
fmt.Printf("%d\n", value)
}
}