Add bool case to ToStringE

This commit is contained in:
Cyrill Schumacher 2015-11-26 07:42:19 +01:00
parent ee815aaf95
commit fc2a835062
2 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,8 @@ func TestToString(t *testing.T) {
assert.Equal(t, ToString(template.URL("http://somehost.foo")), "http://somehost.foo")
assert.Equal(t, ToString(foo), "one more time")
assert.Equal(t, ToString(nil), "")
assert.Equal(t, ToString(true), "true")
assert.Equal(t, ToString(false), "false")
}
type foo struct {

View File

@ -188,6 +188,8 @@ func ToStringE(i interface{}) (string, error) {
switch s := i.(type) {
case string:
return s, nil
case bool:
return strconv.FormatBool(s), nil
case float64:
return strconv.FormatFloat(i.(float64), 'f', -1, 64), nil
case int: