0PricingLogin
Go Academy · Lesson

Pipeline Stages

Chain channel stages.

What Is a Pipeline

A pipeline is a series of stages connected by channels. Each stage receives values, does work, and sends results downstream. Data flows like an assembly line.

  • Each stage is a goroutine
  • Stages communicate only through channels
  • Composable and easy to reason about

Stage Signature Convention

By convention each stage takes one or more receive-only input channels and returns a receive-only output channel. This makes stages chainable.

func stage(in <-chan int) <-chan int {
    out := make(chan int)
    go func() {
        defer close(out)
        for v := range in {
            out <- v
        }
    }()
    return out
}

All lessons in this course

  1. Worker Pool Pattern
  2. Fan-Out Fan-In
  3. Pipeline Stages
  4. Graceful Shutdown
← Back to Go Academy