From ee7b3e0353166ab1f3a605294ac8cd2b77953778 Mon Sep 17 00:00:00 2001 From: Cyrill Schumacher Date: Thu, 26 Nov 2015 07:42:19 +0100 Subject: [PATCH] Add bool case to ToStringE --- cast_test.go | 2 ++ caste.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cast_test.go b/cast_test.go index 2c4e421..e08887b 100644 --- a/cast_test.go +++ b/cast_test.go @@ -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 { diff --git a/caste.go b/caste.go index 5401c0b..3ac4cb7 100644 --- a/caste.go +++ b/caste.go @@ -194,6 +194,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: