1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-12 16:20:39 +00:00

Support Parse Bool with more diffrent values

ParseBool returns the boolean value represented by the string.
It accepts 1, 1.0, t, T, TRUE, true, True, YES, yes, Yes,Y, y, ON, on,
On,
 0, 0.0, f, F, FALSE, false, False, NO, no, No, N,n, OFF, off, Off.
Any other value returns an error.
This commit is contained in:
ysqi
2016-01-23 11:02:40 +08:00
parent af346e871b
commit be544f963e
8 changed files with 202 additions and 118 deletions

View File

@ -92,7 +92,11 @@ type ConfigContainer struct {
// Bool returns the boolean value for a given key.
func (c *ConfigContainer) Bool(key string) (bool, error) {
return strconv.ParseBool(c.data[key].(string))
if v, ok := c.data[key]; ok {
return config.ParseBool(v)
} else {
return false, fmt.Errorf("not exist key: %q", key)
}
}
// DefaultBool return the bool value if has no error