blob: 98f832b969bc0cab758966d327d3d87460d8a3ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// SPDX-License-Identifier: GPL-2.0-only
package utils
import (
"slices"
"strings"
)
// Deduplicate accepts a slice of strings and returns
// a slice which only contains unique items.
func Deduplicate(items []string) []string {
if len(items) > 1 {
slices.Sort(items)
return slices.Compact(items)
} else {
return items
}
}
func SliceTrimSpaces(items []string) (res []string) {
res = make([]string, len(items))
for i, item := range items {
res[i] = strings.TrimSpace(item)
}
return res
}
|