Skip to content

lo

A Go library of Lodash-style helpers for slices, maps, strings and channels, built on generics.

Stars
21.4k
Forks
970
Licence
MIT
Language
Go
Last update
5 days ago
Type
Library

What it is

lo is a Go library that provides many small helper functions for working with slices, maps, strings, channels and functions, such as Map, Filter, Uniq and GroupBy. It is based on Go 1.18+ generics and is modeled loosely on the JavaScript Lodash library. It is used to shorten common code and make it easier to read.

  • Deduplicate a list of strings with lo.Uniq
  • Filter and map a slice of records in one readable chain
  • Group items by a key with GroupBy
  • Split a slice into fixed-size pieces with Chunk

Great for

  • Go developers who often transform slices or maps
  • Teams wanting type-safe helpers instead of repeated loops
  • Developers already familiar with Lodash-style APIs

Not ideal for

  • Projects that must run on Go versions older than 1.18, since it requires generics
  • Developers who prefer only the standard library, because the README says some helpers overlap with the slices and maps packages and the library is a separate dependency
  • Infinite or event-driven data streams, which the README says is the job of the sibling project samber/ro
Step-by-step guide: how to use loInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Go 1.18 or newer

    Install the library

    go get github.com/samber/lo@v1
  2. 2

    Run it

    • Install with go get github.com/samber/lo@v1
    • Import the package with import "github.com/samber/lo"
    • Call a helper, for example names := lo.Uniq([]string{"Samuel", "John", "Samuel"})
    • Browse the full documentation at lo.samber.dev
  3. 3

    Get the most out of it

    • Use the parallel subpackage (github.com/samber/lo/parallel) for parallel versions of some helpers
    • Use the mutable subpackage (github.com/samber/lo/mutable) for in-place operations
    • Use the it subpackage (github.com/samber/lo/it) for iterator-based helpers
    • Browse the GoDoc reference for the full list of helpers across slices, maps, math, strings, tuples and channels

Downloads

Strengths

  • Uses Go generics, so helpers are type-safe
  • No dependencies outside the Go standard library, per the README
  • Versioned under SemVer with a stated promise of no breaking exported API changes before v2.0.0

Trade-offs

  • Some helpers duplicate functions already in Go's standard library slices and maps packages
  • The README itself suggests using the dot-import trick is not recommended
  • Release v1.53.0 ships as a source library with no binaries, so it only matters to Go projects

How it compares

ProjectStarsTypeLevelUpdatedBest for
lo (this)21.4kLibrarybeginner5 days agoGo developers who often transform slices or maps
bubbletea45.6kLibraryintermediate5 days agoGo developers who want to build interactive command-line tools with a visual interface
go-zero33.4kLibraryintermediate5 days agoGo developers building REST APIs or microservices
kit27.4kLibraryadvanced2.3 years agoGo developers building service-oriented or microservice backends
kratos26kLibraryintermediate5 days agoGo developers building a set of backend services that talk over HTTP or gRPC
zap24.7kLibrarybeginner2 months agoGo developers building services that log heavily

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.