Skip to content

net/netip: add IPv6Loopback #51777

Closed
Closed
@mdlayher

Description

@mdlayher

We already have net.IPv6loopback today, but lack an equivalent in net/netip. I'd like to propose adding netip.IPv6Loopback specifically; IPv6 defines exactly one loopback address: ::1.

IPv4 assigns the entire 127.0.0.0/8 and thus should be out of scope for this proposal.

Concretely:

// IPv6Loopback returns the IPv6 loopback address ::1.
func IPv6Loopback() Addr { return AddrFrom16([16]byte{15: 0x01}) }

See also #51766 for a similar addition and rationale. Thanks!

/cc @bradfitz @danderson @josharian

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions