golang 判断ip地址合法性
func isIp(address string) bool {
ip := net.ParseIP(address)
if ip != nil {
return true
}
return false
}
func isIp1(address string) bool {
ipReg := `^((0|[1-9]\d?|1\d\d|2[0-4]\d|25[0-5])\.){3}(0|[1-9]\d?|1\d\d|2[0-4]\d|25[0-5])$`
r, _ := regexp.Compile(ipReg)
match := r.MatchString(address)
if match {
return true
}
return false
}