mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Replace usage of golang.org/x/exp/constraints with Go 1.22 cmp/slices. Update .golangci.yml to new v2 format and enable gofmt/goimports. Refactor imports and type constraints across codebase for consistency.
16 lines
310 B
Go
16 lines
310 B
Go
package underscore
|
|
|
|
import "cmp"
|
|
|
|
// Min returns the minimum value in the slice.
|
|
// This function can currently only compare numbers reliably.
|
|
// This function uses operator <.
|
|
func Min[T cmp.Ordered](values []T) T {
|
|
min := values[0]
|
|
for _, v := range values {
|
|
if v < min {
|
|
min = v
|
|
}
|
|
}
|
|
return min
|
|
}
|