- TryInterface2Int64与TryInterface2Float64,在转字符串为数字不成功时,不报警
This commit is contained in:
@@ -75,7 +75,7 @@ func TryInterface2Int64(data interface{}) (num int64, err error) {
|
||||
return dataNumber.Int64()
|
||||
}
|
||||
if str, ok := data.(string); ok {
|
||||
return Str2Int64(str), nil
|
||||
return Str2Int64WithDefault(str, 0), nil
|
||||
}
|
||||
return 0, fmt.Errorf("data is not json.Number, it's %s, value:%v", reflect.TypeOf(data).String(), data)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TryInterface2Float64(data interface{}) (num float64, err error) {
|
||||
return dataNumber.Float64()
|
||||
}
|
||||
if str, ok := data.(string); ok {
|
||||
return Str2Float64(str), nil
|
||||
return Str2Float64WithDefault(str, 0), nil
|
||||
}
|
||||
return 0, fmt.Errorf("data is not json.Number, it's %s, value:%v", reflect.TypeOf(data).String(), data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user