From 50f71a8a21cac5f5320f965338cba291f05a83de Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Tue, 2 Jun 2020 18:10:17 +0800 Subject: [PATCH] fix bug of getting int error --- config/json.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/config/json.go b/config/json.go index 74c18c9c..07084297 100644 --- a/config/json.go +++ b/config/json.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" + "strconv" "strings" "sync" ) @@ -91,13 +92,7 @@ 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) - if val != nil { - if v, ok := val.(float64); ok { - return int(v), nil - } - return 0, errors.New("not int value") - } - return 0, errors.New("not exist key:" + key) + return strconv.Atoi(val.(string)) } // DefaultInt returns the integer value for a given key.