opengist/internal/utils/slice.go

14 lines
268 B
Go
Raw Normal View History

2023-06-09 13:25:41 +00:00
package utils
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
}