Last Updated: May 22, 2026
A for v := range ch loop pulls values out of a channel one at a time and stops automatically when the sender closes the channel. It replaces the awkward pattern of receiving in a loop and checking the ok flag by hand, but it shifts a responsibility onto the producer: someone has to close the channel, or the receiver waits forever. This lesson covers how range over channels works, who's allowed to close, what goes wrong when nobody does, and the bugs that come from getting the close protocol wrong.