From: Ask Bjørn Hansen Date: Mon, 17 Feb 2014 09:26:46 +0000 (-0800) Subject: Make 'read a string' code understand float64 (json) and int (yaml) as well as actual... X-Git-Tag: v0.10~18 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ed0fe9ddf7b1c5df1d190979a0005747815b732a;p=brevno-suite%2Fhugo Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings --- diff --git a/hugolib/metadata.go b/hugolib/metadata.go index 6d4a19c1..38126ad9 100644 --- a/hugolib/metadata.go +++ b/hugolib/metadata.go @@ -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 ""