1
0
Fork 0
mirror of https://github.com/thomiceli/opengist.git synced 2025-01-25 15:20:36 +00:00
opengist/internal/utils/slice.go
Jacob Hands 4bba26daf6 Add log output config option (#172)
Co-authored-by: Thomas Miceli <27960254+thomiceli@users.noreply.github.com>
2024-01-04 18:06:19 +01:00

22 lines
406 B
Go

package utils
func SliceContains(slice []string, item string) bool {
for _, s := range slice {
if s == item {
return true
}
}
return false
}
func RemoveDuplicates[T string | int](sliceList []T) []T {
allKeys := make(map[T]bool)
list := []T{}
for _, item := range sliceList {
if _, value := allKeys[item]; !value {
allKeys[item] = true
list = append(list, item)
}
}
return list
}