Merge 2e0cffc044
into 1ffadf5510
This commit is contained in:
commit
a4885760a6
@ -6,6 +6,7 @@
|
|||||||
package cast
|
package cast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"testing"
|
"testing"
|
||||||
@ -1051,6 +1052,7 @@ func TestToStringSliceE(t *testing.T) {
|
|||||||
{[]string{"a", "b"}, []string{"a", "b"}, false},
|
{[]string{"a", "b"}, []string{"a", "b"}, false},
|
||||||
{[]interface{}{1, 3}, []string{"1", "3"}, false},
|
{[]interface{}{1, 3}, []string{"1", "3"}, false},
|
||||||
{interface{}(1), []string{"1"}, false},
|
{interface{}(1), []string{"1"}, false},
|
||||||
|
{[]error{errors.New("a"), errors.New("b")}, []string{"a", "b"}, false},
|
||||||
// errors
|
// errors
|
||||||
{nil, nil, true},
|
{nil, nil, true},
|
||||||
{testing.T{}, nil, true},
|
{testing.T{}, nil, true},
|
||||||
|
5
caste.go
5
caste.go
@ -1131,6 +1131,11 @@ func ToStringSliceE(i interface{}) ([]string, error) {
|
|||||||
return v, nil
|
return v, nil
|
||||||
case string:
|
case string:
|
||||||
return strings.Fields(v), nil
|
return strings.Fields(v), nil
|
||||||
|
case []error:
|
||||||
|
for _, err := range i.([]error) {
|
||||||
|
a = append(a, err.Error())
|
||||||
|
}
|
||||||
|
return a, nil
|
||||||
case interface{}:
|
case interface{}:
|
||||||
str, err := ToStringE(v)
|
str, err := ToStringE(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user