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:
@ -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
|
||||
|
Reference in New Issue
Block a user