mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 05:02:03 -05:00
Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings
This commit is contained in:
parent
0926523ba6
commit
91488c7819
1 changed files with 5 additions and 1 deletions
|
@ -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 ""
|
||||
|
|
Loading…
Reference in a new issue