netaddr-go
netaddr-go copied to clipboard
Fill panics if passed the same network
foundSubnets, _ := netaddr.NewIPv4NetList([]string{"10.0.0.0/16"})
supernet, _ := netaddr.ParseIPv4Net("10.0.0.0/16")
filled := supernet.Fill(foundSubnets) // panics because foundSubnets is the same as the supernet 10.0.0.0/16
func (net *IPv4Net) Fill(list IPv4NetList) IPv4NetList {
var subs IPv4NetList
// get rid of non subnets
if list != nil && len(list) > 0 {
for _, e := range list {
isRel, rel := net.Rel(e)
if isRel && rel == 1 { // changing this too ---> isRel && rel == 1 || isRel && rel == 0
subs = append(subs, e)
}
}
// discard subnets of subnets & sort
subs = subs.discardSubnets().Sort() // <-------- panics here becasue subs is empty slice,
} else {
return subs
}