golang 判断IPv4 or IPv6 address

import strings

func IsIPv4(address string) bool {
    return strings.Count(address, ":") < 2
}

func IsIPv6(address string) bool {
    return strings.Count(address, ":") >= 2
}

 

posted @ 2019-10-15 16:45  salami_china  阅读(2884)  评论(0编辑  收藏  举报