Files
lo/docs/data/core-earliestby.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

928 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
EarliestBy earliestby find.go#L462 core find https://go.dev/play/p/0XvCF6vuLXC
core#find#earliestby
core#find#earliestbyerr
core#find#latestby
core#find#earliest
core#find#latest
core#find#minby
core#find#maxby
core#find#minindexby
core#find#maxindexby
core#find#findby
core#find#findkeyby
core#find#findduplicatesby
core#find#finduniquesby
190
func EarliestBy[T any](collection []T, iteratee func(item T) time.Time) T

Searches a collection for the element with the minimum time extracted by the predicate. Returns zero value when the collection is empty.

type Event struct{ At time.Time }
events := []Event{{At: time.Now().Add(2 * time.Hour)}, {At: time.Now()}}
first := lo.EarliestBy(events, func(e Event) time.Time {
    return e.At
})