Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings

This commit is contained in:
Ask Bjørn Hansen 2014-02-17 01:26:46 -08:00 committed by spf13
parent b41622bc49
commit ed0fe9ddf7

View file

@ -149,8 +149,12 @@ func interfaceToString(i interface{}) string {
switch s := i.(type) {
case string:
return s
case float64:
return strconv.FormatFloat(i.(float64), 'f', -1, 64)
case int:
return strconv.FormatInt(int64(i.(int)), 10)
default:
errorf("Only Strings are supported for this key")
errorf(fmt.Sprintf("Only Strings are supported for this key (got type '%T'): %s", s, s))
}
return ""