golang-samber-lo

Implements functional collection transforms in Go using the samber/lo generics library.

Updated Jun 8, 2026
One-click install
npx skills add https://github.com/vovanostm-public/multica --skill golang-samber-lo-vovanostm-public
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/vovanostm-public/multica/tree/main/docs/wiki/architecture/archived-codex-skills/20260525-190000/golang-samber-lo
Command: npx skills add https://github.com/vovanostm-public/multica --skill golang-samber-lo-vovanostm-public

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/samber/lo, and includes references (resource) components.

What problem does it solve? Go's standard library only covers a handful of slice and map helpers, forcing developers to write repetitive manual loops for common operations like Map, Filter, Reduce, and GroupBy. This Skill guides AI coding agents to apply samber/lo's 500+ type-safe generic functions correctly, choosing the right sub-package (immutable, parallel, mutable, or lazy iterators) for each situation. ## Core Features & Use Cases - Functional Transforms: Apply Map, Filter, Reduce, GroupBy, Chunk, Flatten, Uniq, and hundreds more helpers with compile-time type safety and zero external dependencies. - Package Selection Guidance: Choose between core lo (immutable), lop (CPU-bound parallelism), lom (in-place mutation), loi (lazy iterators for Go 1.23+), and experimental SIMD based on profiling evidence. - Pitfall Avoidance: Avoid common mistakes such as using lop for I/O-bound work, discarding immutable return values, or calling lo.Must in request handlers. - Use Case: When refactoring a Go service that filters orders, maps them to summaries, and groups results by status, the Skill produces declarative lo pipelines with proper error variants like MapErr instead of nested loops. ## Quick Start Ask the agent to refactor a Go function that manually loops over a slice into declarative samber/lo transforms with appropriate error handling.

Frequently Asked Questions about golang-samber-lo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use samber/lo for Map, Filter, and Reduce in Go?▼

Import github.com/samber/lo and call lo.Map, lo.Filter, or lo.Reduce with a typed callback receiving the element and index. Each function returns a new collection, so results chain directly without wrapper types or manual loops.

What is the difference between lo, lop, lom, and loi packages?▼

lo is the immutable core for default use. lop parallelizes CPU-bound transforms on large datasets, lom mutates slices in place to eliminate allocations, and loi provides lazy iterators requiring Go 1.23+. Start with lo and switch only after profiling confirms a bottleneck.

Should I use samber/lo or the Go standard library slices package?▼

Prefer stdlib slices.Contains, slices.Sort, and maps.Keys when they cover the operation, since they add no dependency. Use lo for transforms the stdlib lacks, such as Map, Filter, Reduce, GroupBy, Chunk, and Flatten.

Can I use lo/parallel for concurrent HTTP requests in Go?▼

No, lop is designed for CPU-bound parallelism, not I/O-bound work. For concurrent HTTP calls, use errgroup with context cancellation instead, since lop lacks error handling and cancellation support for network operations.

Why does lo.Filter not modify my original slice?▼

lo is immutable by default, so lo.Filter returns a new slice and leaves the input unchanged. Assign the return value to capture results, or use lom.Filter from lo/mutable if you explicitly need in-place mutation.

What Go version is required for samber/lo lazy iterators?▼

The lo/it package (loi) requires Go 1.23 or later because it uses range-over-func for lazy evaluation. The core lo, lop, and lom packages work with Go 1.18+, while the experimental SIMD package needs Go 1.25+ on amd64.