golang-samber-lo

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

Updated May 9, 2026
One-click install
npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-lo-luminavault
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/LuminaVault/LuminaVaultShared/tree/main/.agents/skills/golang-samber-lo
Command: npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-lo-luminavault

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 agents to write declarative, type-safe collection transforms with samber/lo while avoiding common pitfalls like premature optimization, wrong package selection, and immutability misunderstandings. ## Core Features & Use Cases - Package Selection Guidance: Choose correctly between the immutable core (lo), parallel transforms (lop), in-place mutations (lom), lazy iterators (loi, Go 1.23+), and experimental SIMD based on profiling evidence and Go version constraints. - Complete API Reference: Covers 300+ functions across slices, maps, strings, math, tuples, channels, and concurrency, including error variants like MapErr and FilterMap for graceful failure handling. - Use Case: When refactoring a Go service that chains Filter → Map → GroupBy over a large dataset, the Skill recommends lazy loi pipelines to eliminate intermediate allocations, or redirects I/O-bound fan-out to errgroup instead of lop. ## Quick Start Ask the agent to refactor a manual Go loop over a slice into a declarative samber/lo transform such as lo.Map or lo.GroupBy.

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 with type-safe generics. For combined operations, lo.FilterMap maps and filters in a single pass, and error variants like lo.MapErr stop on the first error.

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 transforms the stdlib lacks, such as Map, Filter, Reduce, and GroupBy.

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

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 untouched; discarding the return value is a common bug. If you explicitly need in-place mutation after profiling shows allocation pressure, use lom.Filter instead.

When should I not use lop for parallel processing in Go?▼

Avoid lop for I/O-bound work like HTTP calls, where errgroup with context cancellation is the right tool, and for small datasets under roughly 1000 items where goroutine overhead exceeds the benefit. lop is designed for CPU-bound transforms on large datasets.