12 lines
351 B
Go
12 lines
351 B
Go
package channel
|
|
|
|
// Forward reads all values from all sources and sends them to target.
|
|
// It blocks until all values are forwarded and the out channel was closed.
|
|
// Use with go keyword for non-blocking behavior
|
|
func Forward[T any](target chan<- T, sources ...<-chan T) {
|
|
for value := range Merge(sources...) {
|
|
target <- value
|
|
}
|
|
close(target)
|
|
}
|