Examples

Real-world pipeline recipes showing patterns in action.

Each command ships an /alias package that re-exports its constructor and options under short names. Import the ones you need:

import (
    "os"

    gloo "github.com/gloo-foo/framework"
    grep "github.com/gloo-foo/cmd-grep/alias"
    sort "github.com/gloo-foo/cmd-sort/alias"
    uniq "github.com/gloo-foo/cmd-uniq/alias"
)

Log Processing

Find 5xx errors, sort them, count unique occurrences.
filter accumulate stateful-filter
go

gloo.Run(source, gloo.ByteWriteTo(os.Stdout),
    grep.Grep("5[0-9]{2}", grep.Extended),
    sort.Sort(),
    uniq.Uniq(uniq.Count),
)
Filter selects lines matching 5xx. Accumulate sorts. StatefulFilter deduplicates and counts.

Data Transformation

CSV to JSON, then pluck specific fields.
accumulate map
go

gloo.Run(source, gloo.ByteWriteTo(os.Stdout),
    fromcsv.FromCsv(),
    pluck.Pluck("name", "email"),
)
FromCsv accumulates rows into JSON objects; Pluck maps each object to just the named fields.

Field Extraction

Extract fields 1 and 3 from comma-delimited input.
map
go

gloo.Run(source, gloo.ByteWriteTo(os.Stdout),
    cut.Cut(cut.Fields(1, 3), cut.Delimiter(",")),
)
One Map command. Clean, readable, type-safe.

Multi-Stage ETL

Filter active records, extract a field, number results, take first 10.
filter map stateful-map stateful-filter
go

gloo.Chain(source).
    To(grep.Grep("active", grep.IgnoreCase)).
    To(cut.Cut(cut.Fields(3), cut.Delimiter(","))).
    To(nl.Nl()).
    To(head.Head(head.Lines(10))).
    Sink(gloo.ByteWriteTo(os.Stdout))
FilterMapStatefulMapStatefulFilter. Four patterns, four lines.