mirror of https://github.com/spf13/cast.git
ToStringSliceE: Support string values
This commit is contained in:
parent
2318c5caf2
commit
401c6a67e5
3
caste.go
3
caste.go
|
@ -11,6 +11,7 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
|
@ -292,6 +293,8 @@ func ToStringSliceE(i interface{}) ([]string, error) {
|
||||||
return a, nil
|
return a, nil
|
||||||
case []string:
|
case []string:
|
||||||
return v, nil
|
return v, nil
|
||||||
|
case string:
|
||||||
|
return strings.Split(v, " "), nil
|
||||||
default:
|
default:
|
||||||
return a, fmt.Errorf("Unable to Cast %#v to []string", i)
|
return a, fmt.Errorf("Unable to Cast %#v to []string", i)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue