Skip to content

Commit

Permalink
feat: super 包新增函数 IsNumber,用于判断一个值是否为数字类型
Browse files Browse the repository at this point in the history
  • Loading branch information
kercylan98 committed Aug 26, 2023
1 parent d9ba1bc commit 518d47a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/super/number.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 518d47a

Please sign in to comment.