You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
447 B
20 lines
447 B
package util
|
|
|
|
import "strings"
|
|
|
|
// ParseCSVSet splits a comma-separated string into a set of trimmed,
|
|
// non-empty values. Returns nil if the input is empty.
|
|
func ParseCSVSet(csv string) map[string]bool {
|
|
csv = strings.TrimSpace(csv)
|
|
if csv == "" {
|
|
return nil
|
|
}
|
|
set := make(map[string]bool)
|
|
for _, item := range strings.Split(csv, ",") {
|
|
trimmed := strings.TrimSpace(item)
|
|
if trimmed != "" {
|
|
set[trimmed] = true
|
|
}
|
|
}
|
|
return set
|
|
}
|