feat: super 包新增函数 IsNumber,用于判断一个值是否为数字类型

This commit is contained in:
kercylan98 2023-08-26 09:18:35 +08:00
parent d9ba1bc85c
commit 518d47ae6a
1 changed files with 9 additions and 0 deletions

9
utils/super/number.go Normal file
View File

@ -0,0 +1,9 @@
package super
import "reflect"
// IsNumber 判断是否为数字
func IsNumber(v any) bool {
kind := reflect.Indirect(reflect.ValueOf(v)).Kind()
return kind >= reflect.Int && kind <= reflect.Float64
}