golang IpMask to CIDR
IpMask > CIDR
ones, bits := net.IPv4Mask(255, 255, 255, 248).Size()
fmt.Println(ones,bits)
CIDR > IpMask
_, ipNet, err := net.ParseCIDR("10.95.134.192/29")
if err != nil {
fmt.Println(err)
}
val := make([]byte, len(ipNet.Mask))
copy(val, ipNet.Mask)
var s []string
for _, i := range val[:] {
s = append(s, strconv.Itoa(int(i)))
}
fmt.Printf("%s/%s\n", ipNet.IP, strings.Join(s, "."))