pipeline-pattern-go
Installation
SKILL.md
Pipeline (Go)
Why: Pipeline runs data through a fixed sequence of stages. Each stage receives input, transforms it, and passes the result to the next. All stages run in order; there is no conditional “skip” or early exit (barring errors). You avoid one big function and keep each transformation in its own type.
Hard constraints: Stages share a single interface (e.g. Process(data) (result, error)). A pipeline composes stages in a fixed order and runs them one after another. Flow is linear—no branching or handler-driven termination.
When to use
- Data transformation: Parse → normalize → enrich → serialize, where every step must run.
- ETL / data processing: Ingest, transform, load; or parse log lines, extract fields, aggregate.
- Raw JSON sanitization: Transform/sanitize JSON with one stage per field (or concern) to remove; build the pipeline conditionally from the request (e.g. add removal stages by response type or flags).
- Parsing pipelines: Raw input → tokenize → parse → build AST → emit.
- You need a fixed, mandatory sequence (unlike Chain of Responsibility, where handlers can short-circuit).