pargo

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 4 Imported by: 0

README

Pargo

Generic concurrent collection processing for Go.

Go Version CI License

Pargo helps you process collections concurrently without writing goroutines, channels, or sync.WaitGroup.

Designed for modern Go, Pargo uses generics, context propagation, and a simple API to make parallel processing predictable, readable, and production-ready.


Why Pargo?

Go provides excellent concurrency primitives, but processing collections in parallel still requires repetitive boilerplate.

Instead of writing this:

jobs := make(chan User)
results := make(chan Profile)

var wg sync.WaitGroup

for i := 0; i < workers; i++ {
    go worker(...)
}

You'll write:

profiles, err := pargo.Map(
    ctx,
    users,
    fetchProfile,
)

Cleaner.

Safer.

Easier to maintain.


Features

  • Generic API using Go generics
  • Context-aware operations
  • Configurable worker pool
  • Ordered results by default
  • Functional options
  • Panic recovery
  • Zero external runtime dependencies
  • High-performance concurrent execution

Installation

go get github.com/mohammedimrankasab/pargo

Roadmap

Version Features
v0.1 Parallel Map, worker pool, ordered results, context cancellation
v0.2 Parallel Filter
v0.3 Collection pipelines
v0.4 Batch processing
v0.5 Retry support
v0.6 Streaming collections
v1.0 Stable public API

Design Principles

Pargo follows a few simple principles:

  • Idiomatic Go
  • Generics first
  • Context everywhere
  • Functional options
  • Zero external dependencies
  • Predictable behavior
  • High test coverage
  • Backward compatibility after v1.0

Examples

Basic usage
Map
output, err := pargo.Map(
    ctx,
    input,
    func(ctx context.Context, idx int, value int) (int, error) {
        return value * 2, nil
    },
)

output, err := pargo.Map(
    ctx,
    input,
    mapper,
    pargo.WithWorkers(4),
)

Filter
result, err := pargo.Filter(
    ctx,
    numbers,
    func(ctx context.Context, idx, value int) (bool, error) {
        return value%2 == 0, nil
    },
    pargo.WithWorkers(4),
)

Project Status

🚧 Early Development

Pargo is currently under active development.

The API is still evolving before the first stable release (v1.0.0). Feedback, ideas, bug reports, and contributions are welcome.


Contributing

Please read CONTRIBUTING.md before opening a pull request.


License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter added in v0.2.0

func Filter[T any](
	ctx context.Context,
	items []T,
	fn FilterFunc[T],
	opts ...Option,
) ([]T, error)

Filter returns all items matching the predicate.

The input order is always preserved.

func Map

func Map[T any, R any](
	ctx context.Context,
	items []T,
	fn MapFunc[T, R],
	opts ...Option,
) ([]R, error)

Map concurrently transforms each element of items using fn.

Results preserve the order of the input slice.

Types

type FilterFunc added in v0.2.0

type FilterFunc[T any] func(
	ctx context.Context,
	idx int,
	value T,
) (bool, error)

FilterFunc determines whether a value should be included in the resulting collection.

type MapFunc

type MapFunc[T any, R any] func(context.Context, int, T) (R, error)

Mapper transforms an input value into an output value.

The index corresponds to the item's position in the input slice.

type Option

type Option func(*config)

Option configures the behavior of Map and other collection operations.

func WithWorkers

func WithWorkers(n int) Option

WithWorkers configures the number of worker goroutines.

Values less than or equal to zero are ignored.

Directories

Path Synopsis
examples
basic command
cancellation command
filter command
ordered command
workers command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL