go-samber-lo

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

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-samber-lo-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-samber-lo
Source: https://github.com/asarchami/dotfiles/tree/main/dot_claude/skills/go-samber-lo
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-samber-lo-asarchami

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, GroupBy, and Chunk. This Skill guides an AI agent to write declarative, type-safe data transformations using the samber/lo library instead of boilerplate for-loops. ## Core Features & Use Cases - Functional transforms: Apply 300+ generic helpers (Map, Filter, Reduce, GroupBy, Uniq, Flatten, Zip) with compile-time type safety and zero external dependencies. - Package selection guidance: Choose between immutable core (lo), parallel transforms (lop), in-place mutations (lom), lazy iterators (loi for Go 1.23+), and experimental SIMD based on profiling evidence. - Error-aware patterns: Use Err-suffixed variants like MapErr and FilterErr that stop on the first error instead of manual error collection. - Use Case: When refactoring a Go service that filters paid orders and sums their amounts with nested loops, the agent rewrites it as a composable lo.Filter + lo.Reduce pipeline. ## Quick Start Ask the agent to rewrite a manual Go loop over a slice using samber/lo functions such as lo.Map or lo.GroupBy.

Frequently Asked Questions about go-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 generic callbacks. Chain them directly since each function returns a new slice that feeds into the next.

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

lo is the immutable core for general use, lop runs CPU-bound transforms in parallel goroutines, lom mutates slices in place to avoid allocations, and loi provides lazy iterators for Go 1.23+. Start with lo and switch only when profiling shows a bottleneck.

When should I use samber/lo instead of the Go standard library?

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

Does samber/lo support error handling in Map and Filter?

Yes, most transform functions have Err-suffixed variants like MapErr, FilterErr, and ReduceErr that stop processing on the first error and return it. This avoids manual error collection inside callbacks.

When should I not use the parallel lop package?

Avoid lop for small datasets under roughly 1000 items, trivial transforms, and I/O-bound work, since goroutine overhead exceeds the benefit. For I/O fan-out, use errgroup with context cancellation instead.

Why is lo.Must dangerous in production Go code?

lo.Must panics when the error is non-nil, which can crash request handlers in production. Use it only in tests and initialization code, and handle errors explicitly in production paths.