golang-samber-lo

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

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/santoshkal/chezmoi --skill golang-samber-lo-santoshkal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/santoshkal/chezmoi/tree/main/private_dot_config/opencode/skills/Golang/skills/golang-samber-lo
Command: npx skills add https://github.com/santoshkal/chezmoi --skill golang-samber-lo-santoshkal

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. ## Core Features & Use Cases - Declarative Collection Transforms: Replace manual for-loops with type-safe helpers like lo.Map, lo.Filter, lo.Reduce, lo.GroupBy, lo.Chunk, and lo.Uniq, with error variants (MapErr, FilterErr) that stop on first failure. - Package Selection Guidance: Choose between the immutable core (lo), CPU-parallel transforms (lop), in-place mutations (lom), lazy iterators (loi, 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-bound work, and why lo.Ternary eagerly evaluates both branches. - Use Case: When refactoring a service that filters active users, extracts their emails, and groups them by role, this Skill helps you compose lo.Filter, lo.Map, and lo.GroupBy into a clean pipeline instead of nested loops. ## Quick Start Ask the assistant to refactor a manual Go loop over a slice into declarative samber/lo transforms such as lo.Map and lo.Filter.

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?▼

Use lo.Map to transform each element and lo.Filter to keep elements matching a predicate, both returning new slices without modifying the input. Chain them directly since each function accepts and returns slices, and use lo.MapErr or lo.FilterErr when the transform can fail.

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, lom mutates slices in place to avoid allocations, and loi provides lazy iterators requiring Go 1.23+. Start with lo and switch only after profiling confirms a bottleneck.

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 Chunk.

Can I use lop.Map for concurrent HTTP requests in Go?▼

No, lop is designed for CPU-bound parallelism, not I/O-bound work like HTTP calls. For I/O fan-out use errgroup instead, which provides context cancellation and error propagation that lop lacks.

Does lo.Filter modify the original slice?▼

No, lo.Filter returns a new slice and leaves the input untouched because the core lo package is immutable by default. If you explicitly need in-place mutation after profiling shows allocation pressure, use lom.Filter from the mutable package.

What Go version does samber/lo require?▼

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