Type-safe, composable stream processing for Go.
goflow provides a generic Stream[T] type backed by channels and context. It ships with functional operators (Map, Filter, Reduce, FlatMap) and concurrency primitives (FanOut, FanIn, Process, Tee). Built on gofuncy for goroutine management with OpenTelemetry tracing.
go get github.com/foomo/goflowpackage main
import (
"context"
"fmt"
"github.com/foomo/goflow"
)
func main() {
ctx := context.Background()
result := goflow.Map(
goflow.Of(ctx, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
Filter(func(_ context.Context, n int) bool {
return n%2 == 0
}),
func(_ context.Context, n int) (int, error) {
return n * n, nil
},
).Collect()
fmt.Println(result) // [4 16 36 64 100]
}- Generic
Stream[T]with compile-time type safety - Composable functional operators (Map, Filter, FlatMap, Reduce, and more)
- Built-in concurrency (FanOut, FanIn, FanMap, Process, Tee)
- Context-aware cancellation and timeout propagation
- Channel buffering control via
Pipe iter.Seq/iter.Seq2integration- OpenTelemetry tracing via gofuncy
Contributions are welcome! Please read the contributing guide.
Distributed under MIT License, please see the license file within the code for more details.
