The Or-Channel pattern in Go is implemented by spawning a goroutine for each potential data source and using a select statement to receive from the first channel that sends a value.
func or(c1, c2 <-chan T) <-chan T {
out := make(chan T)
go func() {
select {
case v := <-c1:
out <- v
case v := <-c2:
out <- v
}
}()
return out
}
This pattern extends to multiple channels by adding more case statements inside the select block.