]> Cypherpunks repositories - gostls13.git/commitdiff
net: update IP.MarshalText documentation regarding len(ip) == 0
authorYuval Pavel Zholkover <paulzhol@gmail.com>
Wed, 22 Feb 2017 19:24:44 +0000 (21:24 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 22 Feb 2017 19:59:21 +0000 (19:59 +0000)
Describe the difference from String encoding when len(ip) is zero.

Change-Id: Ia9b36b405d4fec3fee9a77498a839b6d90c2ec0d
Reviewed-on: https://go-review.googlesource.com/37379
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/ip.go

index c482ef63035b390ec6451e720c9a26162a0e776f..db6bc387981c1617930df7f7e9079e013ab6d899 100644 (file)
@@ -340,7 +340,8 @@ func ipEmptyString(ip IP) string {
 }
 
 // MarshalText implements the encoding.TextMarshaler interface.
-// The encoding is the same as returned by String.
+// The encoding is the same as returned by String, with one exception:
+// When len(ip) is zero, it returns an empty slice.
 func (ip IP) MarshalText() ([]byte, error) {
        if len(ip) == 0 {
                return []byte(""), nil