net: make IPv6 String method standards compliant

draft-ietf-6man-text-addr-representation-07 will introduce
a canonical textual representation format for IPv6 address.

R=rsc
CC=golang-dev
https://golang.org/cl/1856047
This commit is contained in:
Mikio Hara 2010-08-12 00:03:01 -07:00 committed by Russ Cox
parent d31ee536e8
commit e41987c821
2 changed files with 48 additions and 0 deletions

View file

@ -222,6 +222,11 @@ func (ip IP) String() string {
e1 = j
}
}
// The symbol "::" MUST NOT be used to shorten just one 16 bit 0 field.
if e1-e0 <= 2 {
e0 = -1
e1 = -1
}
// Print with possible :: in place of run of zeros
var s string