Feature/error code 迁移到各自的包下 (#67)

This commit is contained in:
libin
2024-04-03 11:00:09 +08:00
committed by GitHub
parent b5654c2b4b
commit 5a16cb3559
25 changed files with 124 additions and 109 deletions

View File

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