mirror of
https://github.com/golang/go
synced 2024-11-11 18:31:38 -07:00
net/netip: remove Prefix.Compare for Go 1.22
API questions remain, so we decided to back it out for Go 1.22. Code still lives in the repo, just unexported. For #61642. Change-Id: Iccd91b0da48ae72dec9f660476826a220c7ca4be Reviewed-on: https://go-review.googlesource.com/c/go/+/549615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Anderson <dave@natulte.net> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
e44b8b15b1
commit
d73b4322ed
@ -131,7 +131,6 @@ pkg net/http, func ServeFileFS(ResponseWriter, *Request, fs.FS, string) #51971
|
||||
pkg net/http, method (*Request) PathValue(string) string #61410
|
||||
pkg net/http, method (*Request) SetPathValue(string, string) #61410
|
||||
pkg net/netip, method (AddrPort) Compare(AddrPort) int #61642
|
||||
pkg net/netip, method (Prefix) Compare(Prefix) int #61642
|
||||
pkg os, method (*File) WriteTo(io.Writer) (int64, error) #58808
|
||||
pkg reflect, func PtrTo //deprecated #59599
|
||||
pkg reflect, func TypeFor[$0 interface{}]() Type #60088
|
||||
|
@ -28,3 +28,5 @@ var TestAppendToMarshal = testAppendToMarshal
|
||||
|
||||
func (a Addr) IsZero() bool { return a.isZero() }
|
||||
func (p Prefix) IsZero() bool { return p.isZero() }
|
||||
|
||||
func (p Prefix) Compare(p2 Prefix) int { return p.compare(p2) }
|
||||
|
@ -1261,12 +1261,15 @@ func (p Prefix) isZero() bool { return p == Prefix{} }
|
||||
// IsSingleIP reports whether p contains exactly one IP.
|
||||
func (p Prefix) IsSingleIP() bool { return p.IsValid() && p.Bits() == p.ip.BitLen() }
|
||||
|
||||
// Compare returns an integer comparing two prefixes.
|
||||
// compare returns an integer comparing two prefixes.
|
||||
// The result will be 0 if p == p2, -1 if p < p2, and +1 if p > p2.
|
||||
// Prefixes sort first by validity (invalid before valid), then
|
||||
// address family (IPv4 before IPv6), then prefix length, then
|
||||
// address.
|
||||
func (p Prefix) Compare(p2 Prefix) int {
|
||||
//
|
||||
// Unexported for Go 1.22 because we may want to compare by p.Addr first.
|
||||
// See post-acceptance discussion on go.dev/issue/61642.
|
||||
func (p Prefix) compare(p2 Prefix) int {
|
||||
if c := cmp.Compare(p.Addr().BitLen(), p2.Addr().BitLen()); c != 0 {
|
||||
return c
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user