Skip to content

Commit

Permalink
refactor: Use 'slices.Contains' in 'utils'
Browse files Browse the repository at this point in the history
- Use `slices.Contains` for checking whether an element is contained in a collection.
  • Loading branch information
Laisky committed Jan 26, 2024
1 parent c6cf083 commit 6a8cbb0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"regexp"
"runtime"
"runtime/debug"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -692,13 +693,7 @@ func TrimEleSpaceAndRemoveEmpty(vs []string) (r []string) {

// Contains if collection contains ele
func Contains[V comparable](collection []V, ele V) bool {
for _, v := range collection {
if v == ele {
return true
}
}

return false
return slices.Contains(collection, ele)
}

// IsPtr check if t is pointer
Expand Down

0 comments on commit 6a8cbb0

Please sign in to comment.