代码演示:
//将获取的IpAddr 字符串,转换为10进制
func IpToLong(ipAddress string) (string,uint64) {
var ipSlice []string = strings.Split(ipAddress,".")
var res uint64 =0
for k,v:=range ipSlice{
ip,_:=strconv.ParseUint(v,10,64)
i:=uint64(k)
res |= ip << ((3-i) << 3)
}
return ipAddress,res
}