vrenzolaverace 2aaf2a2158
Use utils helpers libraries (#2809) (#2810)
* Use utils helpers libraries (#2809)

* Use utils helpers libraries (#2809)
2022-11-07 01:54:23 +05:30

17 lines
469 B
Go

package generators
import stringsutil "github.com/projectdiscovery/utils/strings"
// SliceToMap converts a slice of strings to map of string splitting each item at sep as "key sep value"
func SliceToMap(s []string, sep string) map[string]interface{} {
m := make(map[string]interface{})
for _, sliceItem := range s {
key, _ := stringsutil.Before(sliceItem, sep)
value, _ := stringsutil.After(sliceItem, sep)
if key != "" {
m[key] = value
}
}
return m
}