package sliceutil func Unique[T comparable](values []T) []T { if values == nil { return nil } v := make(map[T]struct{}) for _, s := range values { v[s] = struct{}{} } o := make([]T, 0, len(v)) for k := range v { o = append(o, k) } return o }