golang-samber-lo

Transform Go slices and maps with samber/lo functional helpers.

2|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/adibfirman/dotfiles --skill golang-samber-lo-adibfirman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/adibfirman/dotfiles/tree/main/claude/.claude/skills/technical/golang/golang-samber-lo
Command: npx skills add https://github.com/adibfirman/dotfiles --skill golang-samber-lo-adibfirman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you replace repetitive for-loops with declarative, type-safe functional transforms in Go by using samber/lo for common slice, map, string, math, tuple, and concurrency patterns.

Core Features & Use Cases

  • Type-safe functional helpers: Use lo to Map, Filter, Reduce, GroupBy, Chunk, Flatten, and query collections without interface casts.
  • Choose the right performance model: Upgrade to lop for CPU-bound parallelism, lom for in-place mutation, and loi for lazy pipelines on Go 1.23+.
  • Error-aware transformations: Prefer lo.MapErr, lo.FilterErr, and other Err-suffixed variants for correct stop-on-error behavior.

Quick Start

Use the golang-samber-lo skill to refactor this transformation into a composable lo pipeline: "Given users, group active verified emails by role and return a map of role to []email."

Frequently Asked Questions about golang-samber-lo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace repetitive for-loops with declarative functional transforms in Go?

You can replace for-loops with declarative functional transforms in Go by using samber/lo to Map, Filter, Reduce, GroupBy, and Chunk collections in a type-safe manner without interface casts.

What's the best way to handle errors during slice or map transformations in Go?

Handling errors during transformations in Go is best done using samber/lo's Err-suffixed variants like lo.MapErr and lo.FilterErr, which provide correct stop-on-error behavior for robust refactoring.

Does samber/lo support parallel processing for CPU-bound Go transformations?

samber/lo supports parallel processing for CPU-bound Go transformations through the lop package, allowing you to upgrade standard sequential functional operations into concurrent execution.

Can I perform in-place mutable transformations on slices and maps in Go?

You can perform in-place mutation on slices and maps in Go by using the lom package from samber/lo, which provides mutable alternatives to standard immutable functional helpers for memory-efficient processing.

When should I use lazy iterator pipelines for Go collection processing?

Lazy iterator pipelines for Go collection processing should be used with the loi package on Go 1.23+ to defer execution and optimize memory when chaining multiple data reshaping operations.

How do I group and chunk Go slices without writing manual loop logic?

You can group and chunk Go slices without manual loop logic by applying samber/lo's declarative GroupBy and Chunk utilities, enabling type-safe batch data reshaping and flattening.