Go1.22 will support range over function
and introduce the iter
std package.
(Behind the GOEXPERIMENT=rangefunc
gate.)
See more at RangefuncExperiment.
This package provides a set of iterator functions borrowed from Python and Rust.
Some code are copied from Russ Cox's proposals 61898, 61899 and 61900.
go get github.com/j178/it
To use this package, you need to install at least Go 1.22(not released yet) and set GOEXPERIMENT=rangefunc
.
go install golang.org/dl/gotip@latest
gotip download
GOEXPERIMENT=rangefunc gotip run main.go