Range-Over Functions in Go
Follow into
Save into
Iteration has long been one of the more fragmented areas of Go, with developers relying on ad hoc patterns to traverse custom data structures. This article explores the range-over-functions experiment, a proposed evolution of the language that introduces a standardized iterator model while preserving Go’s familiar for range syntax. Using the new iter package and sequence abstractions, it shows how iteration logic can be expressed more clearly, flexibly, and idiomatically. Originally published in April 2024, the concepts remain highly relevant as Go continues to evolve toward more expressive yet simple language features.