diff options
Diffstat (limited to 'pkg/utils/utils.go')
-rw-r--r-- | pkg/utils/utils.go | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index a715ff0..98f832b 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -2,7 +2,7 @@ package utils import ( - "sort" + "slices" "strings" ) @@ -10,20 +10,8 @@ import ( // a slice which only contains unique items. func Deduplicate(items []string) []string { if len(items) > 1 { - sort.Strings(items) - j := 0 - for i := 1; i < len(items); i++ { - if items[j] == items[i] { - continue - } - j++ - // preserve the original data - // in[i], in[j] = in[j], in[i] - // only set what is required - items[j] = items[i] - } - result := items[:j+1] - return result + slices.Sort(items) + return slices.Compact(items) } else { return items } |