From 153c18a515c90a78bf4c90a56e4ba5b700f407b1 Mon Sep 17 00:00:00 2001 From: hopehook Date: Mon, 21 Mar 2022 16:18:00 +0800 Subject: [PATCH] net/netip: improve documentation terminology for IPv4-mapped IPv6 addresses Updates #51834 Change-Id: I07a43457e2e328b51fea8131f7d6d5a4f1de4dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/394078 Trust: Damien Neil Run-TryBot: Damien Neil TryBot-Result: Gopher Robot Reviewed-by: Damien Neil Trust: Ian Lance Taylor Reviewed-by: Emmanuel Odeke --- src/net/netip/netip.go | 8 ++++---- src/net/netip/netip_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index 893eeea7f0d..8fad25db8d3 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.go @@ -456,7 +456,7 @@ func (ip Addr) lessOrEq(ip2 Addr) bool { return ip.Compare(ip2) <= 0 } // Is4 reports whether ip is an IPv4 address. // -// It returns false for IP4-mapped IPv6 addresses. See IP.Unmap. +// It returns false for IPv4-mapped IPv6 addresses. See IP.Unmap. func (ip Addr) Is4() bool { return ip.z == z4 } @@ -675,7 +675,7 @@ const ( ) // As16 returns the IP address in its 16-byte representation. -// IPv4 addresses are returned in their IPv4-mapped IPv6 form. +// IPv4 addresses are returned as IPv4-mapped IPv6 addresses. // IPv6 addresses with zones are returned without their zone (use the // Zone method to get it). // The ip zero value returns all zeroes. @@ -758,7 +758,7 @@ func (ip Addr) Prev() Addr { // - IPv6 with zone ("fe80:db8::1%eth0") // // Note that unlike package net's IP.String method, -// IP4-mapped IPv6 addresses format with a "::ffff:" +// IPv4-mapped IPv6 addresses format with a "::ffff:" // prefix before the dotted quad. func (ip Addr) String() string { switch ip.z { @@ -1380,7 +1380,7 @@ func (p Prefix) Contains(ip Addr) bool { // // If p and o are of different address families or either have a zero // IP, it reports false. Like the Contains method, a prefix with an -// IPv4-mapped IPv6 IP is still treated as an IPv6 mask. +// IPv4-mapped IPv6 address is still treated as an IPv6 mask. func (p Prefix) Overlaps(o Prefix) bool { if !p.IsValid() || !o.IsValid() { return false diff --git a/src/net/netip/netip_test.go b/src/net/netip/netip_test.go index c2811c47030..35f7cd69e11 100644 --- a/src/net/netip/netip_test.go +++ b/src/net/netip/netip_test.go @@ -1757,7 +1757,7 @@ func TestPrefixOverlaps(t *testing.T) { {pfx("1::1/128"), pfx("2::2/128"), false}, {pfx("0100::0/8"), pfx("::1/128"), false}, - // IPv4-mapped IPv6 should not overlap with IPv4. + // IPv4-mapped IPv6 addresses should not overlap with IPv4. {PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false}, // Invalid prefixes