golang-samber-lo

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

1|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/rockcookies/skills --skill golang-samber-lo-rockcookies
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/rockcookies/skills/tree/main/skills/samber-golang/golang-samber-lo
Command: npx skills add https://github.com/rockcookies/skills --skill golang-samber-lo-rockcookies

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 the correct use of samber/lo's 500+ type-safe generic functions and helps you choose between its core, parallel, mutable, and lazy-iterator packages without falling into performance or correctness traps. ## Core Features & Use Cases - Functional Transforms: Apply Map, Filter, Reduce, GroupBy, Chunk, Flatten, Uniq, and hundreds more helpers to slices, maps, strings, channels, and tuples with compile-time type safety. - Package Selection Guidance: Choose between lo (immutable core), lop (parallel CPU-bound work), lom (in-place mutation), loi (lazy iterators, Go 1.23+), and experimental SIMD based on profiling evidence. - Pitfall Avoidance: Learn when stdlib slices/maps packages are preferable, why lop is wrong for I/O fan-out, why lo.Must belongs only in init code, and how error variants like MapErr stop on first failure. - Use Case: When refactoring a handler that filters orders, maps them to DTOs, and groups them by status, replace nested loops with a composable lo.Filter → lo.Map → lo.GroupBy pipeline. ## Quick Start Ask the agent to refactor a Go function that uses manual for-loops into declarative samber/lo transforms, or to review existing lo usage for correctness and performance.

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 to map and filter slices in Go?▼

Call lo.Map with a transform function and lo.Filter with a predicate; both take the slice plus a callback receiving each element and its index. They return new slices without modifying the input, so assign the result: filtered := lo.Filter(users, func(u User, _ int) bool { return u.Active }).

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

lo is the immutable core returning new collections. lop runs CPU-bound transforms in parallel goroutines for large datasets. lom mutates slices in place to eliminate allocations. loi provides lazy iterators requiring Go 1.23+ that avoid intermediate allocations in chained pipelines.

Should I use lo.Contains or slices.Contains in Go?▼

Prefer stdlib slices.Contains and slices.Sort since Go 1.21, and slices.Collect(maps.Keys(m)) since Go 1.23, because they carry no dependency. Use lo only for operations the stdlib lacks, such as Map, Filter, Reduce, GroupBy, and predicate-based queries like ContainsBy.

Can I use lop.Map 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 context support and spawns goroutine-per-element overhead that provides no benefit for network waits.

Does samber/lo work with Go 1.20?▼

The core lo, lop, and lom packages require Go 1.18+, so they work with Go 1.20. However, the lo/it lazy iterator package requires Go 1.23+ because it uses range-over-func, and the experimental SIMD package requires Go 1.25+ on amd64.

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

lo is immutable by default: every core function allocates and returns a new collection rather than modifying its input. If you discard the return value, the original slice is unchanged. Use lom.Filter when you explicitly need in-place mutation and accept losing the original data.