default
This commit is contained in:
14
tools/checkid.go
Normal file
14
tools/checkid.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package tools
|
||||
|
||||
import "regexp"
|
||||
|
||||
// CheckID 验证id是否为非负正整数。
|
||||
func CheckID(id string) bool {
|
||||
if id == "1" {
|
||||
return false
|
||||
}
|
||||
pattern := `^[1-9]\d*$`
|
||||
reg := regexp.MustCompile(pattern)
|
||||
return reg.MatchString(id)
|
||||
}
|
||||
|
Reference in New Issue
Block a user