2017-04-30 09:22:07 +00:00
|
|
|
package provider
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
// SplitAndTrimString splits separatedString at the comma character and trims each
|
|
|
|
// piece, filtering out empty pieces. Returns the list of pieces or nil if the input
|
|
|
|
// did not contain a non-empty piece.
|
2017-11-28 10:16:03 +00:00
|
|
|
func SplitAndTrimString(base string) []string {
|
|
|
|
var trimmedStrings []string
|
|
|
|
|
|
|
|
for _, s := range strings.Split(base, ",") {
|
2017-04-30 09:22:07 +00:00
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
if len(s) > 0 {
|
2017-11-28 10:16:03 +00:00
|
|
|
trimmedStrings = append(trimmedStrings, s)
|
2017-04-30 09:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-28 10:16:03 +00:00
|
|
|
return trimmedStrings
|
2017-04-30 09:22:07 +00:00
|
|
|
}
|