Skip to content

foomo/goflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status Go Report Card GoDoc

goflow

goflow

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.

Install

go get github.com/foomo/goflow

Quick Example

package 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]
}

Features

  • 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.Seq2 integration
  • OpenTelemetry tracing via gofuncy

Documentation

How to Contribute

Contributions are welcome! Please read the contributing guide.

Contributors

License

Distributed under MIT License, please see the license file within the code for more details.

Made with ♥ foomo by bestbytes

About

Type-safe, composable stream processing for Go

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors