1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 20:41:57 +00:00

Improve memstore's GetBoolDefault

Former-commit-id: db47fcf76eaf09ea9d63bae2623c61a1af435c39
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-09-29 03:58:43 +03:00
parent 1a57504431
commit bff09c1a93

View File

@@ -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
}