mirror of
https://github.com/containous/traefik.git
synced 2024-12-24 21:34:39 +03:00
20 lines
567 B
Go
20 lines
567 B
Go
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.
|
|
func SplitAndTrimString(separatedString string) []string {
|
|
listOfStrings := strings.Split(separatedString, ",")
|
|
var trimmedListOfStrings []string
|
|
for _, s := range listOfStrings {
|
|
s = strings.TrimSpace(s)
|
|
if len(s) > 0 {
|
|
trimmedListOfStrings = append(trimmedListOfStrings, s)
|
|
}
|
|
}
|
|
|
|
return trimmedListOfStrings
|
|
}
|