Skip to content

Commit 99ee1bc

Browse files
committed
refactor: use a more modern writing style
Signed-off-by: hardlydearly <799511800@qq.com>
1 parent bb3744d commit 99ee1bc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sdk/utils/utils.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"os"
88
"os/signal"
9+
"slices"
910
"sort"
1011
"time"
1112

@@ -26,12 +27,7 @@ func Unique[T comparable](arr []T) []T {
2627
}
2728

2829
func Belongs[T comparable](input []T, elem T) bool {
29-
for _, e := range input {
30-
if e == elem {
31-
return true
32-
}
33-
}
34-
return false
30+
return slices.Contains(input, elem)
3531
}
3632

3733
func Map[T, U any](input []T, f func(T) U) []U {
@@ -43,7 +39,7 @@ func Map[T, U any](input []T, f func(T) U) []U {
4339
}
4440

4541
func Uint32Sort(arr []uint32) {
46-
sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
42+
slices.Sort(arr)
4743
}
4844

4945
// Context for API requests

0 commit comments

Comments
 (0)