Merge pull request #719 from gzliudan/fix-sa1021

p2p/netutil: fix staticcheck warning SA1021: use bytes.Equal to compare two net.IP
This commit is contained in:
Daniel Liu 2024-11-01 11:36:06 +08:00 committed by GitHub
commit 0454aa32df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -212,7 +212,7 @@ func sameNet(bits uint, ip, other net.IP) bool {
if mask != 0 && nb < len(ip) && ip[nb]&mask != other[nb]&mask {
return false
}
return nb <= len(ip) && bytes.Equal(ip[:nb], other[:nb])
return nb <= len(ip) && ip[:nb].Equal(other[:nb])
}
// DistinctNetSet tracks IPs, ensuring that at most N of them