Skip to content

Commit

Permalink
Use generics in sliceutil
Browse files Browse the repository at this point in the history
  • Loading branch information
abicky committed Oct 28, 2024
1 parent db2b939 commit be28f56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/sliceutil/sliceutil.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package sliceutil

func Contains(slice []string, str string) bool {
func Contains[T comparable](slice []T, v T) bool {
for _, elem := range slice {
if elem == str {
if elem == v {
return true
}
}
return false
}

func ChunkSlice(slice []*string, size int) chan []*string {
ch := make(chan []*string)
func ChunkSlice[T any](slice []T, size int) chan []T {
ch := make(chan []T)
go func() {
for i := 0; i < len(slice); i += size {
end := i + size
Expand Down

0 comments on commit be28f56

Please sign in to comment.