From c804fd8927dabe1484b52e31f752136b7c0b32b7 Mon Sep 17 00:00:00 2001 From: Yuval Pavel Zholkover Date: Wed, 22 Feb 2017 21:24:44 +0200 Subject: [PATCH] net: update IP.MarshalText documentation regarding len(ip) == 0 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 --- src/net/ip.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/net/ip.go b/src/net/ip.go index c482ef6303..db6bc38798 100644 --- a/src/net/ip.go +++ b/src/net/ip.go @@ -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 -- 2.50.0