1 Star 0 Fork 0

danlansky/go-library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
func.go 690 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangminghua 提交于 11个月前 . feat:基础工具包
package utils
import (
"errors"
"gorm.io/gorm"
"regexp"
"strconv"
)
func IsRecordNotFoundError(err error) bool {
return errors.Is(err, gorm.ErrRecordNotFound)
}
//获取分页数量
func PageNum(total, pageSize int) (pageNum int) {
if total <= 0 {
return
}
if pageSize <= 1 {
return total
}
pageNum = total / pageSize
if total%pageSize > 0 {
pageNum++
}
return
}
//mobile verify
func VerifyMobileFormat(mobileNum string) bool {
//非严格检测
regular := "^(1\\d{10})$"
reg := regexp.MustCompile(regular)
return reg.MatchString(mobileNum)
}
//判断字符串是否为数字
func IsNum(s string) bool {
_, err := strconv.ParseFloat(s, 64)
return err == nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/danlansky/go-library.git
git@gitee.com:danlansky/go-library.git
danlansky
go-library
go-library
v1.0.7

搜索帮助