Skip to content

Commit

Permalink
update: 优化byte数值审核(#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchuanchuan committed Mar 20, 2023
1 parent 8ab939e commit 25739df
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions session/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,23 +968,13 @@ func Min(x, y int) int {

// IsNumeric 判断是否为数字
func IsNumeric(val interface{}) bool {
// switch str := val.(type) {
// case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
// case float32, float64, complex64, complex128:
// return true
// case string:
// for _, v := range str {
// if !unicode.IsNumber(v) {
// return false
// }
// }
// }
// return false
switch v := val.(type) {
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
return true
case float32, float64, complex64, complex128:
return true
case []byte:
return true
case string:
str := v
if str == "" {
Expand Down Expand Up @@ -1025,6 +1015,8 @@ func IsNumeric(val interface{}) bool {
}
}
return true
default:
// fmt.Printf("%#v %T\n", v, v)
}

return false
Expand Down

0 comments on commit 25739df

Please sign in to comment.