return string(buf)
default:
// TODO: this could be more efficient allocation-wise:
- return joinHostPort(p.ip.String(), itoa.Itoa(int(p.port)))
+ return "[" + p.ip.String() + "]:" + itoa.Uitoa(uint(p.port))
}
}
-func joinHostPort(host, port string) string {
- // We assume that host is a literal IPv6 address if host has
- // colons.
- if bytealg.IndexByteString(host, ':') >= 0 {
- return "[" + host + "]:" + port
- }
- return host + ":" + port
-}
-
// AppendTo appends a text encoding of p,
// as generated by MarshalText,
// to b and returns the extended buffer.
want string
}{
{mustIPPort("1.2.3.4:80"), "1.2.3.4:80"},
+ {mustIPPort("[::]:80"), "[::]:80"},
{mustIPPort("[1::CAFE]:80"), "[1::cafe]:80"},
{mustIPPort("[1::CAFE%en0]:80"), "[1::cafe%en0]:80"},
{mustIPPort("[::FFFF:192.168.140.255]:80"), "[::ffff:192.168.140.255]:80"},