diff --git a/bool.go b/bool.go index 6fa1015..3d0be47 100644 --- a/bool.go +++ b/bool.go @@ -94,9 +94,9 @@ func str2bool(str string) (bool, error) { } switch strings.ToLower(strings.TrimSpace(str)) { - case "on": + case "on", "yes", "y": return true, nil - case "off": + case "off", "no", "n": return false, nil default: return false, newErr(str, "bool") diff --git a/bool_test.go b/bool_test.go index a9b0983..faff8ed 100644 --- a/bool_test.go +++ b/bool_test.go @@ -158,6 +158,10 @@ func TestBoolE(t *testing.T) { {uint8(0.00), false, false}, {nil, false, false}, {false, false, false}, + {"NO", false, false}, + {"no", false, false}, + {"N", false, false}, + {"n", false, false}, {"false", false, false}, {"FALSE", false, false}, {"False", false, false}, @@ -195,6 +199,10 @@ func TestBoolE(t *testing.T) { // true/scale {true, true, false}, + {"YES", true, false}, + {"yes", true, false}, + {"Y", true, false}, + {"y", true, false}, {"true", true, false}, {"TRUE", true, false}, {"True", true, false},