net: document UDPConn.ReadFromUDPAddrPort's AddrPort result more

Clarify the form of its IPv4 addresses when listening on an
unspecified address.

(found while testing/reviewing CL 399454)

Change-Id: I62b367f5a4e6d340eb72dd7ec342080f1821e63e
Reviewed-on: https://go-review.googlesource.com/c/go/+/419614
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Brad Fitzpatrick 2022-07-26 13:29:16 -07:00 committed by Gopher Robot
parent faf4e97200
commit 4248146154

View file

@ -164,6 +164,10 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
}
// ReadFromUDPAddrPort acts like ReadFrom but returns a netip.AddrPort.
//
// If c is bound to an unspecified address, the returned
// netip.AddrPort's address might be an IPv4-mapped IPv6 address.
// Use netip.Addr.Unmap to get the address without the IPv6 prefix.
func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) {
if !c.ok() {
return 0, netip.AddrPort{}, syscall.EINVAL