explaingit

samber/lo

📈 Trending21,227GoAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Go library with 200+ utility functions for slices, maps, strings, and channels, powered by generics. Like Lodash for Go.

Mindmap

mindmap
  root((lo))
    What it does
      Filter and map
      Group and chunk
      Sort and search
    Data types
      Slices
      Maps
      Strings
      Channels
    Features
      No dependencies
      Generics support
      Parallel variants
    Use cases
      Data transformation
      Collection operations
      Concurrent patterns

Things people build with this

USE CASE 1

Filter, map, and transform slices and maps in your Go applications without writing boilerplate code.

USE CASE 2

Group and chunk data for batch processing or organize results by category.

USE CASE 3

Implement fan-in/fan-out concurrency patterns using channel utilities.

USE CASE 4

Deduplicate, sort, and search collections with one-liner helper functions.

Tech stack

GoGo 1.18+Generics

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

lo is a utility library for the Go programming language that brings the kind of compact, expressive helpers people are used to from JavaScript's Lodash. Its starting point is Go 1.18, the version that introduced generics: with generics, you can write a function once that works for any element type, which is what makes a clean Filter/Map/Reduce style finally possible in Go without copying the same function for every type you might pass in. Practically, the library is a single package (with a few sub-packages such as lo/parallel, lo/mutable, and lo/it) that adds dozens of small functions for working with slices, maps, strings, channels, tuples, time durations, and math. The slice section alone covers familiar moves like Filter, Map, Reduce, Uniq, GroupBy, Chunk, Flatten, Reverse, Shuffle, Take, Drop, Reject, Count, Replace, Compact, plus more specialized ones like Window, Sliding, PartitionBy, and CountValuesBy. The map section adds operations such as Keys, Values, PickBy, OmitBy, Entries, Invert, Assign, MapKeys, and MapValues. There are also set-style intersection helpers (Contains, Every, Some, Intersect, Difference, Union, Without), search helpers (IndexOf, Find, HasPrefix), string casers (PascalCase, CamelCase, KebabCase, SnakeCase), math helpers (Sum, Product, Mean, Mode, Range, Clamp), and channel helpers (FanIn, FanOut, Buffer, Generator) for concurrent code. Usage typically looks like calling lo.Uniq(...) on a slice and getting a deduplicated slice back, with the type figured out by the compiler. The author notes that a handful of helpers overlap with what is now in Go's standard slices and maps packages, but argues that lo still offers many more abstractions beyond those. The library has no dependencies outside the Go standard library, is at v1 and follows semantic versioning so exported APIs are stable until v2, and ships an AI-agent "skill" that other tools can install. You would reach for this library if you write Go and find yourself repeatedly writing the same small loops to filter, deduplicate, group, or transform collections, and would prefer one-line helpers that read clearly. The author also points to companion libraries, samber/mo for monadic types like Option and Result, samber/do for dependency injection, and samber/ro for reactive streams, if you want the rest of the same ergonomic style. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
Show me how to use lo to filter a slice of structs by a condition and map the results to a new type.
Prompt 2
How do I use lo's channel utilities to implement a fan-out pattern that processes items concurrently?
Prompt 3
Write a Go function using lo that groups a slice of objects by a field and returns a map of groups.
Prompt 4
How can I use lo's parallel variants to speed up filtering and mapping operations on large slices?
Prompt 5
Show me an example of using lo to deduplicate and sort a slice of strings in one chain.
Open on GitHub → Explain another repo

Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.