Handling complex cases where input matches expected output

This commit is contained in:
spf13 2014-04-07 11:42:50 -04:00
parent 559d57776b
commit d6ad1120de

View File

@ -139,6 +139,8 @@ func ToStringMapStringE(i interface{}) (map[string]string, bool) {
for k, val := range v { for k, val := range v {
m[ToString(k)] = ToString(val) m[ToString(k)] = ToString(val)
} }
case map[string]string:
return v, true
default: default:
return m, false return m, false
} }
@ -154,6 +156,8 @@ func ToStringMapE(i interface{}) (map[string]interface{}, bool) {
for k, val := range v { for k, val := range v {
m[ToString(k)] = val m[ToString(k)] = val
} }
case map[string]interface{}:
return v, true
default: default:
return m, false return m, false
} }
@ -169,6 +173,8 @@ func ToStringSliceE(i interface{}) ([]string, bool) {
for _, u := range v { for _, u := range v {
a = append(a, ToString(u)) a = append(a, ToString(u))
} }
case []string:
return v, true
default: default:
return a, false return a, false
} }