lo is a Lodash-inspired Go library built on Go 1.18+ generics. It adds typed helpers for slices, maps, strings, channels, and functions.
Overview
The lo package is a utility library for Go programs that rely on generics introduced in Go 1.18. It collects many small functions for transforming and querying slices, maps, strings, channels, tuples, times, and errors with compile-time type safety.
Documented helpers span filtering, mapping, reductions, grouping, set operations, searching, sorting checks, string case conversions, channel fan-in and fan-out patterns, debouncing, throttling, and parallel variants of several slice operations. Some overlap exists with newer standard library packages slices and maps, but the project positions itself as offering a broader set of abstractions in one place.
The module follows semantic versioning with no dependencies beyond the Go standard library. A separate ro project is referenced for infinite stream processing, while lo focuses on finite sequences such as slices and maps.
API reference is published on GoDoc and a dedicated documentation site, with playground examples for many helpers.
Key features
- Generic slice map and filter helpers
- Map key, value, and entry utilities
- Set-style intersect and union operations
- Channel dispatch and fan-in/out tools
- String casing and chunk helpers
- Debounce, throttle, and async utilities
- Parallel map and foreach variants
- Error try/catch style helpers
Use cases
- Collection transforms in Go services
- Readable slice and map pipelines
- Typed alternatives to hand-rolled loops
- Channel-based concurrency utilities