golang-samber-lo

Perform type-safe functional transformations on Go slices and maps with samber/lo.

1|Updated May 27, 2026
One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-lo-dmwin72015
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-samber-lo
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-lo-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It removes repetitive boilerplate for transforming and grouping data in Go slices and maps, so developers can express intent directly instead of hand-writing error-prone loops.

Core Features & Use Cases

  • Type-safe functional transforms: map/filter/reduce, grouping, chunking, flattening, and deduplication for slices and maps.
  • Error-aware variants: functions with Err suffixes (e.g., MapErr, FilterErr, ReduceErr) that stop early and return errors.
  • Performance options: choose immutable core (lo) by default, switch to concurrent CPU-bound transforms (lop) when appropriate, use in-place mutations (lom) only on validated hot paths, and use lazy iterators (loi) for large multi-step pipelines on Go 1.23+.

Use Case: Transform a list of uploaded file metadata into per-type groups (video/audio/images/docs) by filtering on type, mapping to a normalized representation, then grouping by category for downstream indexing or media processing.

Quick Start

Use the golang-samber-lo skill to refactor your slice transformation into lo.Map/lo.Filter/lo.GroupBy (or loi for lazy pipelines) to implement a clear, type-safe collection workflow.

Frequently Asked Questions about golang-samber-lo

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

FAQPage Schema
How do I perform type-safe map and filter operations on slices in Go?

Type-safe map and filter operations on slices in Go are performed using functional programming helpers that execute declarative transformations, preventing boilerplate loops and ensuring collection elements match expected types.

What is the best way to group and chunk slice data in Go without writing loops?

The best way to group and chunk slice data in Go is using functional collection transforms that handle grouping, chunking, and deduplication declaratively. This removes repetitive loop boilerplate and allows developers to express data transformation intent directly for downstream indexing.

How do I stop slice iteration early when an error occurs in Go transforms?

To stop slice iteration early when an error occurs in Go transforms, use error-aware variants with an Err suffix, such as MapErr or FilterErr. These functions halt operations immediately upon encountering an error and return it, preventing silent failures in data pipelines.

When should I use lazy iterators instead of standard slice transforms in Go?

Lazy iterators should be used instead of standard slice transforms in Go for large multi-step pipelines on Go 1.23+. The lazy evaluation module processes elements on demand, which optimizes memory consumption and performance across complex sequential data transformation workflows.

Does samber/lo support concurrent processing for CPU-bound slice transformations?

Yes, samber/lo supports concurrent processing for CPU-bound slice transformations through its dedicated parallel module. This allows developers to switch from immutable core operations to parallel execution when optimizing performance-heavy batch data workloads.

When should I not use in-place mutations for Go collection transforms?

You should not use in-place mutations for Go collection transforms outside of validated hot paths. The mutation module modifies data directly for performance tuning, which sacrifices the immutable-by-default safety of the core package and risks unintended side effects.