mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
f3b738b250
fix: potential division by zero (see #199)
18 lines
326 B
Go
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
|
|
}
|