mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-18 21:04:30 +08:00
Feature/error code 迁移到各自的包下 (#67)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package jsonUtil
|
||||
|
||||
import (
|
||||
"github.com/jefferyjob/go-easy-utils/v2"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
@@ -46,7 +45,7 @@ func toInt64(i any) (int64, error) {
|
||||
case string:
|
||||
intValue, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return 0, go_easy_utils.ErrSyntax
|
||||
return 0, ErrSyntax
|
||||
}
|
||||
return intValue, nil
|
||||
case int:
|
||||
@@ -97,7 +96,7 @@ func toInt64(i any) (int64, error) {
|
||||
// }
|
||||
// intValue, err := strconv.ParseInt(*v, 10, 64)
|
||||
// if err != nil {
|
||||
// return 0, go_easy_utils.ErrSyntax
|
||||
// return 0, ErrSyntax
|
||||
// }
|
||||
// return intValue, nil
|
||||
//case *int:
|
||||
@@ -111,7 +110,7 @@ func toInt64(i any) (int64, error) {
|
||||
//case *int64:
|
||||
// return *v, nil
|
||||
default:
|
||||
return 0, go_easy_utils.ErrType
|
||||
return 0, ErrType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ func toInt64Reflect(i any) (int64, error) {
|
||||
}
|
||||
intValue, err := strconv.ParseInt(v.String(), 10, 64)
|
||||
if err != nil {
|
||||
return 0, go_easy_utils.ErrSyntax
|
||||
return 0, ErrSyntax
|
||||
}
|
||||
return intValue, nil
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
@@ -155,6 +154,6 @@ func toInt64Reflect(i any) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
default:
|
||||
return 0, go_easy_utils.ErrType
|
||||
return 0, ErrType
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user