File: strings.go

package info (click to toggle)
golang-github-theupdateframework-go-tuf 0.5.2-5~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 7,596 kB
  • sloc: python: 163; sh: 37; makefile: 12
file content (24 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package sets

func StringSliceToSet(items []string) map[string]struct{} {
	s := map[string]struct{}{}
	for _, item := range items {
		s[item] = struct{}{}
	}
	return s
}

func StringSetToSlice(items map[string]struct{}) []string {
	ret := []string{}

	for k := range items {
		ret = append(ret, k)
	}

	return ret
}

func DeduplicateStrings(items []string) []string {
	s := StringSliceToSet(items)
	return StringSetToSlice(s)
}