Commit 7b5d5367 authored by Mikio Hara's avatar Mikio Hara

net: ensure that ResolveIPAddr(addr.String()) reproduces addr

Updates #6465.

Change-Id: I5babbcf4c92dae47c823a41628b01e4ceb2332eb
Reviewed-on: https://go-review.googlesource.com/11951
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent a625b919
...@@ -38,6 +38,8 @@ var resolveIPAddrTests = []resolveIPAddrTest{ ...@@ -38,6 +38,8 @@ var resolveIPAddrTests = []resolveIPAddrTest{
{"", "127.0.0.1", &IPAddr{IP: IPv4(127, 0, 0, 1)}, nil}, // Go 1.0 behavior {"", "127.0.0.1", &IPAddr{IP: IPv4(127, 0, 0, 1)}, nil}, // Go 1.0 behavior
{"", "::1", &IPAddr{IP: ParseIP("::1")}, nil}, // Go 1.0 behavior {"", "::1", &IPAddr{IP: ParseIP("::1")}, nil}, // Go 1.0 behavior
{"ip4:icmp", "", &IPAddr{}, nil},
{"l2tp", "127.0.0.1", nil, UnknownNetworkError("l2tp")}, {"l2tp", "127.0.0.1", nil, UnknownNetworkError("l2tp")},
{"l2tp:gre", "127.0.0.1", nil, UnknownNetworkError("l2tp:gre")}, {"l2tp:gre", "127.0.0.1", nil, UnknownNetworkError("l2tp:gre")},
{"tcp", "1.2.3.4:123", nil, UnknownNetworkError("tcp")}, {"tcp", "1.2.3.4:123", nil, UnknownNetworkError("tcp")},
......
...@@ -17,10 +17,11 @@ func (a *IPAddr) String() string { ...@@ -17,10 +17,11 @@ func (a *IPAddr) String() string {
if a == nil { if a == nil {
return "<nil>" return "<nil>"
} }
ip := ipEmptyString(a.IP)
if a.Zone != "" { if a.Zone != "" {
return a.IP.String() + "%" + a.Zone return ip + "%" + a.Zone
} }
return a.IP.String() return ip
} }
func (a *IPAddr) isWildcard() bool { func (a *IPAddr) isWildcard() bool {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment