A Go library providing functional programming helpers like map, filter, and reduce with concurrency support.
Underscore is a Go library that provides functional programming utilities for data transformation and manipulation. It offers a comprehensive set of helpers for collections, concurrency, and utilities, enabling more expressive and efficient code without extending Go's built-in objects. The library is a port of Underscore.js, leveraging Go's generics and type safety.
Go developers who need functional programming patterns like map, filter, and reduce for slice and collection operations, especially those working on data processing or concurrent applications. It's also suitable for developers familiar with Underscore.js who want similar utilities in Go.
Developers choose Underscore for its familiar functional utilities from Underscore.js, combined with Go's type safety and built-in concurrency features like ParallelMap and ParallelFilter. It provides a pragmatic approach to functional programming in Go, with a fluent Pipe/Chain API for method chaining and additional subpackages for map transformations.
🌟 Useful functional programming helpers for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers a wide range of functions like map, filter, reduce, chunk, and groupBy, making data manipulation expressive and familiar from Underscore.js, as listed in the Collections section of the README.
Provides ParallelMap and ParallelFilter with context cancellation and order preservation, enabling efficient concurrent processing without manual goroutine management, demonstrated in the README examples with workers and error handling.
NewPipe allows method chaining for readable data transformations, with methods returning wrapped values until Value is called, enhancing code clarity as described in the Pipe section.
Leverages Go 1.18+ generics to ensure type-safe operations without extending built-in objects, aligning with Go's philosophy while adding functional capabilities, as noted in the Philosophy.
Functional utilities like map and filter can introduce slight overhead due to function calls and allocations compared to raw loops, which may impact performance-sensitive applications.
Requires Go 1.24 or later, limiting compatibility with older projects and potentially causing breaking changes with future Go updates, as specified in the Prerequisites.
As a standalone library, it might not seamlessly integrate with other Go frameworks or tools compared to more mature utility sets, and the README doesn't mention community plugins or extensions.