1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/utils/set.go
Ferdinand Mütsch f3b738b250 fix: empty projects (resolve #197)
fix: potential division by zero (see #199)
2021-05-03 21:32:26 +02:00

18 lines
326 B
Go

package utils
func StringsToSet(slice []string) map[string]bool {
set := make(map[string]bool, len(slice))
for _, e := range slice {
set[e] = true
}
return set
}
func SetToStrings(set map[string]bool) []string {
slice := make([]string, 0, len(set))
for k := range set {
slice = append(slice, k)
}
return slice
}