15 lines
236 B
Go
15 lines
236 B
Go
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)
|
|
}
|
|
|