# Simplify Go Collections with samber/lo

Repetitive collection transformations and helper logic can obscure Go application code. This skill shows concise samber/lo patterns for collections, errors, concurrency, pointers, and related utilities.

## Install

```bash
npx skillstore add dcjanus/golang-lo
```

## Metadata

- Status: approved
- Slug: dcjanus-golang-lo
- Skillstore revision: r2
- Version status: missing
- Tree hash: 296e080d23db71c3518e1fbb8286e24479d1a6dc9ed8f61fb146143dba1db18d
- Author: DCjanus
- GitHub username: DCjanus
- License: MIT
- Repository: https://github.com/DCjanus/prompts/tree/master/skills/golang-lo
- Ref: c43861a65bb95efcae259cd161c9d6f4dc7eec6f
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: scripts, external\_commands, network
- Quality score: 50
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/dcjanus-golang-lo
- Manifest: https://skillstore.pages.dev/api/skills/dcjanus-golang-lo/manifest

## Capabilities

- Provides the Go command for adding samber/lo version 1.
- Shows imports for the core, parallel, mutable, and iterator packages.
- Demonstrates Filter, Map, Find, Uniq, GroupBy, and Must with short examples.
- Explains when Must can panic and where initialization use is appropriate.
- Points to the upstream function list and warns that it may differ from released versions.

## Use Cases

- Refactor Collection Pipelines: Replace repetitive slice filtering, mapping, deduplication, lookup, and grouping logic with focused generic helpers.
- Review Helper Usage: Check whether samber/lo calls preserve behavior, expose missing cases, and use panic-based helpers only where intentional.
- Standardize Team Patterns: Create consistent guidance for common collection transformations while retaining native loops when they are clearer.

## Prompt Templates

### Filter and Map a Slice

```
Using samber/lo in Go 1.18, show how to filter even integers and map them to squares. Explain each return type.
```

### Find and Deduplicate Values

```
Refactor my slice logic with Find and Uniq. Preserve first-seen order and handle the case where no matching item exists.
```

### Group Records Safely

```
Design a samber/lo pipeline that groups users by age. Explain error handling and avoid Must outside application initialization.
```

### Review a Concurrent Pipeline

```
Review my collection pipeline for core, parallel, mutable, or iterator helpers. Discuss cancellation, shared state, allocations, readability, and native Go alternatives.
```

## Limitations

- Requires Go 1.18 or later because samber/lo uses generics.
- Covers only a small selection of library functions.
- Does not compare performance or allocations with native Go loops.
- The remote function list may describe unreleased behavior and requires version verification.

## Best Practices

- Confirm examples against the samber/lo version recorded in go.mod.
- Use Must only when failure should stop initialization.
- Prefer clear native Go when a helper would hide control flow or allocation costs.

## Anti Patterns

- Do not fetch and trust mutable remote documentation without reviewing its source and version.
- Do not replace every loop with helpers when readability or performance becomes worse.
- Do not use parallel helpers for shared mutable state without synchronization.

## Security Audit

- Audited at: 2026-07-23T17:03:26.187\+00:00
- Summary: Six shell-execution alerts, the dynamic-import alert, and the entropy heuristic are false positives caused by Markdown fences, Go syntax, and readable Chinese text. The curl instruction is genuine outbound network access, and the guide also relies on a moving dependency selector and mutable remote documentation. No credential access, obfuscation, destructive behavior, or direct prompt injection was found.

## Stats

- Views: 216
- Downloads: 7
- Favorites: 0
- Popularity score: 0
