1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:55:01 -07:00

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 <bradfitz@golang.org>
This commit is contained in:
Yuval Pavel Zholkover 2017-02-22 21:24:44 +02:00 committed by Brad Fitzpatrick
parent 8c6643846e
commit c804fd8927

View 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