talira

Lodash-style generic helpers for Go slices, maps, strings, channels and functions

open sourceMITfree

lo (samber/lo) is a Lodash-style utility library for Go built on Go 1.18+ generics: type-safe helpers such as Filter, Map, Reduce, Uniq, GroupBy, Chunk and many more for slices, maps, strings, channels and functions. It has parallel versions of some helpers (lo/parallel), versions that change slices in place (lo/mutable) and iterator versions (lo/it). It has no dependencies outside the standard library, is at v1 and follows SemVer strictly, with no breaking changes to exported APIs before v2 outside its experimental exp/ packages.

Problems it solves

  • filter, map and reduce slices in Go without writing loops every time
  • remove duplicates from a slice in Go with generics
  • group a Go slice by a key into a map
  • find whether a slice contains a value in Go
  • split a Go slice into chunks
  • run a map over a slice in parallel goroutines

Features

  • Generic helpers for slices, maps, strings, channels and functions
  • Filter, Map, Reduce, Uniq, GroupBy, Chunk and more
  • Parallel helpers (lo/parallel)
  • In-place helpers (lo/mutable)
  • Iterator helpers (lo/it)
  • No dependencies outside the standard library
  • v1 with strict SemVer