Files
lo/docs/data/core-uniqby.md
T
2025-10-06 17:15:49 +02:00

629 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
UniqBy uniqby slice.go#L160 core slice https://go.dev/play/p/g42Z3QSb53u
core#slice#uniqby
core#slice#uniq
core#slice#uniqmap
core#slice#partitionby
110
func UniqBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice

Returns a duplicate-free version of a slice based on a computed key. Keeps only the first element for each unique key.

lo.UniqBy(
    []int{0, 1, 2, 3, 4, 5},
    func(i int) int {
        return i % 3
    },
)
// []int{0, 1, 2}