diff --git a/count.go b/count.go index 581c053..9a3d287 100644 --- a/count.go +++ b/count.go @@ -2,7 +2,7 @@ package underscore // Count returns the number of elements in the slice that satisfy the predicate. // example: Count([]int{1,2,3,4,5}, func(n int) bool { return n%2 == 0 }) // 2 -func Count[T comparable](slice []T, predicate func(T) bool) int { +func Count[T any](slice []T, predicate func(T) bool) int { count := 0 for _, item := range slice { if predicate(item) { diff --git a/count_test.go b/count_test.go index 9a876ef..cef8e32 100644 --- a/count_test.go +++ b/count_test.go @@ -1,9 +1,10 @@ package underscore import ( - "github.com/stretchr/testify/assert" "strings" "testing" + + "github.com/stretchr/testify/assert" ) func Test_Count_Can_Count_Numbers(t *testing.T) { @@ -21,7 +22,7 @@ type People struct { Gender string } -func Test_Count_Can_Count__People(t *testing.T) { +func Test_Count_Can_Count_People(t *testing.T) { people := []People{ {Name: "Andy", Age: 43, Gender: "M"}, {Name: "Fred", Age: 33, Gender: "M"},