This repository has been archived on 2025-07-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
hn84/util/util.go
2023-11-05 09:15:01 +00:00

21 lines
375 B
Go

package util
import (
"fmt"
)
func Wrap(label string, err error) error {
return fmt.Errorf("%s: %w", label, err)
}
func Deduplicate[T comparable](sliceList []T) []T {
allKeys := make(map[T]struct{})
var list []T
for _, item := range sliceList {
if _, value := allKeys[item]; !value {
allKeys[item] = struct{}{}
list = append(list, item)
}
}
return list
}