explaingit

samber/lo

Analysis updated 2026-06-21

21,227GoAudience · developerComplexity · 2/5Setup · easy

TLDR

lo is a Go utility library that adds Lodash-style helpers like Filter, Map, GroupBy, and Uniq for slices, maps, and channels, all type-safe using Go generics, with no external dependencies.

Mindmap

mindmap
  root((repo))
    What it does
      Utility helpers
      Type-safe generics
      No dependencies
    Slice helpers
      Filter Map Reduce
      Uniq GroupBy Chunk
      Flatten Reverse
    Map helpers
      Keys Values
      PickBy OmitBy
      MapKeys MapValues
    Other helpers
      Set operations
      String casers
      Channel helpers
    Audience
      Go developers
      Backend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Replace repetitive slice-filtering loops in Go with one-line calls like lo.Filter and lo.Map.

USE CASE 2

Group, deduplicate, or transform Go slices and maps without writing custom helper functions each time.

USE CASE 3

Use lo/parallel to process large collections concurrently across goroutines with the same clean API.

USE CASE 4

Perform set operations like Intersect, Union, and Difference on Go slices in a single line.

What is it built with?

Go

How does it compare?

samber/lochaitin/safelinelima-vm/lima
Stars21,22721,22620,954
LanguageGoGoGo
Setup difficultyeasymoderatemoderate
Complexity2/54/53/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

lo is a utility library for the Go programming language by Samuel Berthe. It brings to Go the kind of compact, expressive helpers that JavaScript developers know from Lodash. The starting point is Go 1.18, the version that introduced generics. Generics let you write one function that works for any element type, which is what makes a clean Filter, Map, and Reduce style possible in Go without rewriting the same function for every type. The library is a single Go module with a few sub-packages. The main package adds dozens of small functions for working with slices, maps, strings, channels, tuples, time durations, and math. There is a parallel sub-package called lo/parallel for running those helpers across goroutines, a mutable sub-package called lo/mutable that modifies the input in place when that is faster, and an iterator-based sub-package called lo/it. Installation is one go get command, and the library has no dependencies outside the Go standard library. The author keeps it at v1 and follows semantic versioning, so exported APIs will not change before v2. The slice section alone covers familiar moves like Filter, Map, Reduce, Uniq, GroupBy, Chunk, Flatten, Reverse, Shuffle, Take, Drop, Reject, Count, Replace, and Compact, along with more specialised 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 set helpers such as Contains, Every, Some, Intersect, Difference, Union, and Without. There are string casers for PascalCase, CamelCase, KebabCase, and SnakeCase. There are math helpers for Sum, Product, Mean, Mode, Range, and Clamp. There are channel helpers such as FanIn, FanOut, Buffer, and Generator for concurrent code. The author notes that a few of the helpers overlap with what is now in Go's standard slices and maps packages, but argues the library still offers many more shapes beyond those. You would reach for lo if you write Go and find yourself 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 sibling libraries: samber/mo for option and result types, samber/do for dependency injection, and samber/ro for reactive streams over infinite data sources.

Copy-paste prompts

Prompt 1
Show me how to use lo.Filter and lo.Map to transform a slice of structs in Go without writing loops.
Prompt 2
How do I use lo.GroupBy to organize a slice of records by a field value in Go?
Prompt 3
Write a Go snippet using lo.Uniq and lo.Intersect to find common unique items between two slices.
Prompt 4
How do I use lo/parallel to process a large slice concurrently with a map operation in Go?
Prompt 5
Show me how to use lo's string case helpers like PascalCase and SnakeCase to normalize identifiers in Go.

Frequently asked questions

What is lo?

lo is a Go utility library that adds Lodash-style helpers like Filter, Map, GroupBy, and Uniq for slices, maps, and channels, all type-safe using Go generics, with no external dependencies.

What language is lo written in?

Mainly Go. The stack also includes Go.

How hard is lo to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is lo for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub samber on gitmyhub

Verify against the repo before relying on details.