Senior
Do you remember when the range became available through the channel?
sobes.tech AI
Answer from AI
In Go, the range operator over a channel has been available since the earliest versions of the language, starting with Go 1.0.
This is a fundamental feature that allows iterating over values received from a channel until it is closed.
Example:
ch := make(chan int)
go func() {
for i := 0; i < 5; i++ {
ch <- i
}
close(ch)
}()
for val := range ch {
fmt.Println(val)
}
Thus, range over a channel is a standard and long-standing construct in Go.