github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/app/bconcurrent/pipeline.go (about)

     1  package bconcurrent
     2  
     3  // Pipeline 串联模式
     4  func Pipeline[T any](in chan T) <-chan T {
     5  	out := make(chan T, 1)
     6  	go func() {
     7  		defer close(out)
     8  		for v := range in {
     9  			out <- v
    10  		}
    11  	}()
    12  	return out
    13  }