Go makes you write the same little loops again and again — filter a list, group it, find one item, split it into chunks; samber/lo has all of them already written and type-safe.
WHEN TO USE
SCOPE
USE FOR
Transform a slice or map with a declarative Map, Filter, or Reduce call instead of a loop.
Choose between lo's immutable, parallel, mutable, or lazy-iterator variants for a workload.
Chain Filter, Map, and GroupBy calls into one readable transform pipeline.
Stop a batch transform on its first error using lo's Err-suffixed variants.
NOT FOR
Streaming pipelines over infinite or asynchronous event streams.
This is a saved copy of the skill's SKILL.md instructions. It may differ from the upstream file or the version you install.
Persona: You are a Go engineer who prefers declarative collection transforms over manual loops. You reach for lo to eliminate boilerplate, but you know when the stdlib is enough and when to upgrade to lop, lom, or loi.
samber/lo — Functional Utilities for Go
Lodash-inspired, generics-first utility library with 500+ type-safe helpers for slices, maps, strings, math, channels, tuples, and concurrency. Zero external dependencies. Immutable by default.
This skill is not exhaustive — refer to library documentation and code examples for more information:
For Go package docs, symbols, versions, importers, and known vulnerabilities, → See samber/cc-skills-golang@golang-pkg-go-dev skill (godig), preferred over Context7 for Go package facts.
To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See samber/cc-skills-golang@golang-gopls skill (gopls).
Context7 remains a fallback for docs not indexed on pkg.go.dev.
Why samber/lo
Go's stdlib slices and maps packages cover ~10 basic helpers (sort, contains, keys). Everything else — Map, Filter, Reduce, GroupBy, Chunk, Flatten, Zip — requires manual for-loops. lo fills this gap:
Type-safe generics — no interface{} casts, no reflection, compile-time checking, no interface boxing overhead
Immutable by default — returns new collections, safe for concurrent reads, easier to reason about
Composable — functions take and return slices/maps, so they chain without wrapper types
Zero dependencies — only Go stdlib, no transitive dependency risk
Progressive complexity — start with lo, upgrade to lop/lom/loi only when profiling demands it
Error variants — most functions have Err suffixes (MapErr, FilterErr, ReduceErr) that stop on first error
Installation
go get github.com/samber/lo
Package
Import
Alias
Go version
Core (immutable)
github.com/samber/lo
lo
1.18+
Parallel
github.com/samber/lo/parallel
lop
1.18+
Mutable
github.com/samber/lo/mutable
lom
1.18+
Iterator
github.com/samber/lo/it
loi
1.23+
SIMD (experimental)
github.com/samber/lo/exp/simd
—
1.25+ (amd64 only)
Choose the Right Package
Start with lo. Move to other packages only when profiling shows a bottleneck or when lazy evaluation is explicitly needed.
Package
Use when
Trade-off
lo
Default for all transforms
Allocates new collections (safe, predictable)
lop
CPU-bound work on large datasets (1000+ items)
Goroutine overhead; not for I/O or small slices
lom
Hot path confirmed by pprof -alloc_objects
Mutates input — caller must understand side effects
loi
Large datasets with chained transforms (Go 1.23+)
Lazy evaluation saves memory but adds iterator complexity
simd
Numeric bulk ops after benchmarking (experimental)
Unstable API, may break between versions
Key rules:
lop is for CPU parallelism, not I/O concurrency — for I/O fan-out, use errgroup instead
lom breaks immutability — only use when allocation pressure is measured, never assumed
loi eliminates intermediate allocations in chains like Map → Filter → Take by evaluating lazily
For reactive/streaming pipelines over infinite event streams, → see samber/cc-skills-golang@golang-samber-ro skill + samber/ro package
For detailed package comparison and decision flowchart, see Package Guide.
Use lo.Map — lop benefits start at ~1000+ items for CPU-bound work
Assuming lo.Filter modifies the input
lo is immutable by default — it returns a new slice
Use lom.Filter if you explicitly need in-place mutation
Using lo.Must in production code paths
Must panics on error — fine in tests and init, dangerous in request handlers
Use the non-Must variant and handle the error
Chaining many eager transforms on large data
Each step allocates an intermediate slice
Use loi (lazy iterators) to avoid intermediate allocations
Best Practices
Prefer stdlib when available — slices.Contains and slices.Sort (Go 1.21+) carry no dependency; maps.Keys is Go 1.23+ and returns an iterator, so use slices.Collect(maps.Keys(m)) when you need a slice. Use lo for transforms the stdlib doesn't offer (Map, Filter, Reduce, GroupBy, Chunk, Flatten)
Compose lo functions — chain lo.Filter → lo.Map → lo.GroupBy instead of writing nested loops. Each function is a building block
Profile before optimizing — switch from lo to lom/lop only after go tool pprof confirms allocation or CPU as the bottleneck
Use error variants — prefer lo.MapErr over lo.Map + manual error collection. Error variants stop early and propagate cleanly
Use lo.Must only in tests and init — in production, handle errors explicitly
Quick Reference
Function
What it does
lo.Map
Transform each element
lo.Filter / lo.Reject
Keep / remove elements matching predicate
lo.Reduce
Fold elements into a single value
lo.ForEach
Side-effect iteration
lo.GroupBy
Group elements by key
lo.Chunk
Split into fixed-size batches
lo.Flatten
Flatten nested slices one level
lo.Uniq / lo.UniqBy
Remove duplicates
lo.Find / lo.FindOrElse
First match or default
lo.Contains / lo.Every / lo.Some
Membership tests
lo.Keys / lo.Values
Extract map keys or values
lo.PickBy / lo.OmitBy
Filter map entries
lo.Zip2 / lo.Unzip2
Pair/unpair two slices
lo.Range / lo.RangeFrom
Generate number sequences
lo.Ternary / lo.If
Inline conditionals
lo.ToPtr / lo.FromPtr
Pointer helpers
lo.Must / lo.Try
Panic-on-error / recover-as-bool
lo.Async / lo.Attempt
Async execution / retry with backoff
lo.Debounce / lo.Throttle
Rate limiting
lo.ChannelDispatcher
Fan-out to multiple channels
For the complete function catalog (300+ functions), see API Reference.
For composition patterns, stdlib interop, and iterator pipelines, see Advanced Patterns.
Run this outside your AI tool, using Node.js 22.20.0 or newer. Skills CLI 1.7.2 skips skill selection; prompts cancel installation without an interactive terminal. If choosing Project when asked about installation scope, open your project's folder before running this.
Install checklist
Check selected tools if a picker appears; Claude Code may be unchecked under Additional agents. ↑/↓ moves, Space toggles selections, Enter confirms.
Without a tool picker, check Installing to: for your intended tool. Stop if it names a different tool.
If asked, choose Symlink (Recommended) for shared files or Copy to all agents for separate copies; review the summary before confirming installation.
Install the find-skills skill? defaults to Yes, adding another skill for all projects. Choose No if you don't want that extra installation.
Skills CLI 1.7.2 sends install data to skills.sh by default, including the source, skill names, target tools and file details; GitHub sources are reported only when GitHub confirms the repository is public, while other remote sources can also be reported. Confirmed-public GitHub sources also trigger a security-audit request. Before installing, set the environment variable DO_NOT_TRACK=1 or DISABLE_TELEMETRY=1 to disable both.
After installing for Claude Code, open it in the installation project if you chose Project; Global makes the skill available across projects on this computer. Once Claude Code loads the skill, its description helps Claude decide when to use it.
If installation created a top-level skills folder that did not exist when your Claude Code session started, run /reload-skills in that session. Run it again after later changes in that folder.
Install the whole plugin
This route installs the Samber Golang Skills plugin package selected for your AI tool.
Add Samuel's marketplace, then install the plugin
Type both lines inside a Claude Code session, not at your shell prompt. The marketplace is a separate repository of Samuel Berthe's, samber/cc, which also lists his other plugins. The second line opens the details of cc-skills-golang, which carries this repository's 46 Go skills; pick one of the install options shown and Claude Code installs it.
01
/plugin marketplace add samber/cc
02
/plugin install cc-skills-golang@samber
Run it in your terminal. It copies the whole repository, with its 46 skills, into ~/.openclaw/skills/cc-skills-golang, OpenClaw's skills folder in your home folder. To install it for one OpenClaw workspace instead, Samuel gives ~/.openclaw/workspace/skills/cc-skills-golang as the folder.
Run it in your terminal, not inside Gemini CLI; installing from GitHub needs git on your computer. It installs the repository, with its 46 skills, as a Gemini CLI extension. To update it later, run gemini extensions update cc-skills-golang.
Run it in your terminal. It copies the whole repository, with its 46 skills, into ~/.cursor/skills/cc-skills-golang, Cursor's skills folder in your home folder.
Type it in an interactive GitHub Copilot CLI session, not at your shell prompt. It installs the repository straight from GitHub as a plugin, with its 46 skills and no marketplace to add first.
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while samber/cc-skills-golang@golang-performance provides the optimization patterns.Read full description
Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI unit testing. Also triggers when code uses cobra, viper, or urfave/cli. For cobra-specific APIs → See samber/cc-skills-golang@golang-spf13-cobra skill; for viper configuration layering → See samber/cc-skills-golang@golang-spf13-viper skill.Read full description
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See samber/cc-skills-golang@golang-naming skill), linter configuration (→ See samber/cc-skills-golang@golang-lint skill), or doc comments (→ See samber/cc-skills-golang@golang-documentation skill).Read full description
Golang concurrency patterns. Use when writing or reviewing concurrent Go code involving goroutines, channels, select, locks, sync primitives, errgroup, singleflight, worker pools, or fan-out/fan-in pipelines. Also triggers when you detect goroutine leaks, race conditions, channel ownership issues, or need to choose between channels and mutexes.Read full description
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background/TODO/WithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.Read full description
CI/CD pipeline configuration using GitHub Actions for Golang projects — testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate, GoReleaser, code review automation, and release pipelines. Use when setting up or improving Go project CI, configuring GitHub Actions workflows, adding linters or security scanners, automating dependency updates, or adding quality gates.Read full description