golang-samber-lo

Select the correct samber/lo package for Go collection transforms and iteration.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-samber-lo-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-lo
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-samber-lo
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-samber-lo-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps engineers choose and apply the right samber/lo package for collection transforms, concurrency, and lazy iteration in Go without guessing between immutable, mutable, parallel, or experimental options.

Core Features & Use Cases

  • Core transforms: Use lo for map, filter, reduce, group, chunk, flatten, and error-aware variants across slices, maps, channels, strings, tuples, and numbers.
  • Performance choices: Switch to lop for CPU-bound parallel work, lom for measured in-place optimization, loi for Go 1.23+ lazy pipelines, and simd only when benchmarking justifies it.
  • Practical guidance: It explains stdlib interop, version constraints, immutability behavior, and when to avoid lo for I/O fan-out or infinite streaming pipelines.
  • Use case: A developer can ask whether to use lo.Map, lop.Map, lom.Filter, or loi.Take for a specific dataset and get a safe, idiomatic recommendation.

Quick Start

Ask me to review your Go transformation task and recommend the correct samber/lo package, import path, and usage pattern for your data shape and Go version.

Frequently Asked Questions about golang-samber-lo

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

FAQPage Schema
What's the best way to handle Go collection transforms like map, filter, and reduce across slices and maps?

Use the core samber/lo package for standard Go collection transforms like map, filter, and reduce across slices, maps, and channels. It provides idiomatic, immutable helpers for finite batch processing without writing boilerplate loops.

How do I choose between samber/lo and parallel processing packages for CPU-bound Go tasks?

Switch to the lop package for CPU-bound parallel work in Go, while using core lo for standard immutable transforms. Choose lop when you need to distribute heavy collection processing across multiple CPU cores efficiently.

Can I use lazy iterators for Go pipeline transforms with samber/lo?

Yes, use the loi package for Go 1.23+ lazy iterators. It allows you to build lazy pipelines for collection transforms, deferring execution until results are explicitly consumed, which optimizes memory for large datasets.

When should I use mutable in-place Go collection transforms instead of immutable options?

Use the lom package when you need measured in-place optimization for Go collection transforms. Choose mutable transforms when benchmarking proves that avoiding memory allocation overhead is critical for your specific performance bottleneck.

Does samber/lo work with I/O fan-out and infinite streaming pipelines in Go?

No, you should avoid using samber/lo for I/O fan-out or infinite streaming pipelines. The packages are designed for finite batch processing across data structures like slices, maps, and channels, not unbounded continuous data streams.

How do I handle errors during Go slice and map transformations?

Use the error-aware variants provided by the core samber/lo package for Go collection transforms. These specialized functions allow your map and filter operations to return errors safely, halting or aggregating failures during batch processing.