mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
14 lines
247 B
Go
14 lines
247 B
Go
package utils
|
|
|
|
func RemoveDuplicate[T comparable](slice []T) []T {
|
|
seen := make(map[T]struct{})
|
|
var result []T
|
|
for _, v := range slice {
|
|
if _, ok := seen[v]; !ok {
|
|
seen[v] = struct{}{}
|
|
result = append(result, v)
|
|
}
|
|
}
|
|
return result
|
|
}
|