[go] net/netip: update godoc comments

1 view
Skip to first unread message

Tobias Klauser (Gerrit)

unread,
4:42 AM (3 hours ago) 4:42 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Tobias Klauser has uploaded the change for review

Commit message

net/netip: update godoc comments

Streamline the godoc comments across Addr, AddrPort and Prefix in terms
of wording and godoc links. Add more and correct godoc links.
Change-Id: Id806ddcfafc9a99af483a9a6c94c6288d1ee4939

Change diff

diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go
index 5a78820..e622799 100644
--- a/src/net/netip/netip.go
+++ b/src/net/netip/netip.go
@@ -95,9 +95,9 @@
}
}

-// AddrFrom16 returns the IPv6 address given by the bytes in addr.
-// An IPv4-mapped IPv6 address is left as an IPv6 address.
-// (Use Unmap to convert them if needed.)
+// AddrFrom16 returns the IPv6 address given by the bytes in addr. An
+// IPv4-mapped IPv6 address is left as an IPv6 address (use [Addr.Unmap] to
+// convert them if needed).
func AddrFrom16(addr [16]byte) Addr {
return Addr{
addr: uint128{
@@ -957,15 +957,15 @@
return string(ret)
}

-// AppendText implements the [encoding.TextAppender] interface,
-// It is the same as [Addr.AppendTo].
+// AppendText implements the [encoding.TextAppender] interface. The encoding is
+// the same as returned by [Addr.AppendTo].
func (ip Addr) AppendText(b []byte) ([]byte, error) {
return ip.AppendTo(b), nil
}

-// MarshalText implements the [encoding.TextMarshaler] interface,
-// The encoding is the same as returned by [Addr.String], with one exception:
-// If ip is the zero [Addr], the encoding is the empty string.
+// MarshalText implements the [encoding.TextMarshaler] interface. The encoding
+// is the same as returned by [Addr.String], with one exception: If ip is the
+// zero [Addr], the encoding is the empty string.
func (ip Addr) MarshalText() ([]byte, error) {
buf := []byte{}
switch ip.z {
@@ -985,7 +985,7 @@
return ip.AppendText(buf)
}

-// UnmarshalText implements the encoding.TextUnmarshaler interface.
+// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
// The IP address is expected in a form accepted by [ParseAddr].
//
// If text is empty, UnmarshalText sets *ip to the zero [Addr] and
@@ -1034,7 +1034,7 @@
}

// UnmarshalBinary implements the [encoding.BinaryUnmarshaler] interface.
-// It expects data in the form generated by MarshalBinary.
+// It expects data in the form generated by [Addr.MarshalBinary].
func (ip *Addr) UnmarshalBinary(b []byte) error {
n := len(b)
switch {
@@ -1201,15 +1201,15 @@
return b
}

-// AppendText implements the [encoding.TextAppender] interface. The
-// encoding is the same as returned by [AddrPort.AppendTo].
+// AppendText implements the [encoding.TextAppender] interface. The encoding is
+// the same as returned by [AddrPort.AppendTo].
func (p AddrPort) AppendText(b []byte) ([]byte, error) {
return p.AppendTo(b), nil
}

-// MarshalText implements the [encoding.TextMarshaler] interface. The
-// encoding is the same as returned by [AddrPort.String], with one exception: if
-// p.Addr() is the zero [Addr], the encoding is the empty string.
+// MarshalText implements the [encoding.TextMarshaler] interface. The encoding
+// is the same as returned by [AddrPort.String], with one exception: if p.Addr()
+// is the zero [Addr], the encoding is the empty string.
func (p AddrPort) MarshalText() ([]byte, error) {
buf := []byte{}
switch p.ip.z {
@@ -1224,9 +1224,9 @@
return p.AppendText(buf)
}

-// UnmarshalText implements the encoding.TextUnmarshaler
-// interface. The [AddrPort] is expected in a form
-// generated by [AddrPort.MarshalText] or accepted by [ParseAddrPort].
+// UnmarshalText implements the [encoding.TextUnmarshaler] interface. The
+// [AddrPort] is expected in a form generated by [AddrPort.MarshalText] or
+// accepted by [ParseAddrPort].
func (p *AddrPort) UnmarshalText(text []byte) error {
if len(text) == 0 {
*p = AddrPort{}
@@ -1513,9 +1513,9 @@
return p.AppendTo(b), nil
}

-// MarshalText implements the [encoding.TextMarshaler] interface,
-// The encoding is the same as returned by [Prefix.String], with one exception:
-// If p is the zero value, the encoding is the empty string.
+// MarshalText implements the [encoding.TextMarshaler] interface. The encoding
+// is the same as returned by [Prefix.String], with one exception: If p is the
+// zero [Prefix], the encoding is the empty string.
func (p Prefix) MarshalText() ([]byte, error) {
buf := []byte{}
switch p.ip.z {
@@ -1530,7 +1530,7 @@
return p.AppendText(buf)
}

-// UnmarshalText implements the encoding.TextUnmarshaler interface.
+// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
// The IP address is expected in a form accepted by [ParsePrefix]
// or generated by [Prefix.MarshalText].
func (p *Prefix) UnmarshalText(text []byte) error {
@@ -1543,7 +1543,7 @@
return err
}

-// AppendBinary implements the [encoding.AppendMarshaler] interface.
+// AppendBinary implements the [encoding.BinaryAppender] interface.
// It returns [Addr.AppendBinary] with an additional byte appended
// containing the prefix bits.
func (p Prefix) AppendBinary(b []byte) ([]byte, error) {

Change information

Files:
  • M src/net/netip/netip.go
Change size: S
Delta: 1 file changed, 23 insertions(+), 23 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id806ddcfafc9a99af483a9a6c94c6288d1ee4939
Gerrit-Change-Number: 779640
Gerrit-PatchSet: 1
Gerrit-Owner: Tobias Klauser <tobias....@gmail.com>
Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Florian Lehner (Gerrit)

unread,
7:38 AM (1 hour ago) 7:38 AM
to Tobias Klauser, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Ian Lance Taylor, Damien Neil, Nicholas Husin, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Damien Neil, Ian Lance Taylor, Nicholas Husin and Tobias Klauser

Florian Lehner voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Ian Lance Taylor
  • Nicholas Husin
  • Tobias Klauser
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Id806ddcfafc9a99af483a9a6c94c6288d1ee4939
    Gerrit-Change-Number: 779640
    Gerrit-PatchSet: 1
    Gerrit-Owner: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Florian Lehner <lehner.f...@gmail.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
    Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Nicholas Husin <n...@golang.org>
    Gerrit-Comment-Date: Tue, 19 May 2026 11:38:48 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages