mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
Improve memstore's GetBoolDefault
Former-commit-id: db47fcf76eaf09ea9d63bae2623c61a1af435c39
This commit is contained in:
parent
1a57504431
commit
bff09c1a93
|
@ -274,9 +274,22 @@ func (r *Store) GetBoolDefault(key string, def bool) (bool, error) {
|
|||
if v == nil {
|
||||
return def, nil
|
||||
}
|
||||
|
||||
if vBoolean, ok := v.(bool); ok {
|
||||
return vBoolean, nil
|
||||
}
|
||||
|
||||
if vString, ok := v.(string); ok {
|
||||
return strconv.ParseBool(vString)
|
||||
}
|
||||
|
||||
if vInt, ok := v.(int); ok {
|
||||
if vInt == 1 {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return def, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user