package main
import (
"log"
"regexp"
)
// 判断是否为内网IP,如果是内网ip, 则返回 true
func isIntranet(ip string) bool {
match1 := regexp.MustCompile(`^(10|100|192|172|127)\.`).FindString(ip)
return len(match1) != 0
}
func main() {
log.SetFlags(log.Lshortfile)
log.Println("192", isIntranet("192.168.1.1")) //true
log.Println("123", isIntranet("123.12.12.12")) //false
}