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

fix CI and UT

This commit is contained in:
Ming Deng
2020-06-06 18:16:36 +08:00
parent b8efb3ef45
commit 5100a8c396
3 changed files with 25 additions and 3 deletions

View File

@ -92,7 +92,15 @@ func (c *JSONConfigContainer) DefaultBool(key string, defaultval bool) bool {
// Int returns the integer value for a given key.
func (c *JSONConfigContainer) Int(key string) (int, error) {
val := c.getData(key)
return strconv.Atoi(val.(string))
if val != nil {
if v, ok := val.(float64); ok {
return int(v), nil
} else if v, ok := val.(string); ok {
return strconv.Atoi(v)
}
return 0, errors.New("not int value")
}
return 0, errors.New("not exist key:" + key)
}
// DefaultInt returns the integer value for a given key.