Skip to content

Commit

Permalink
net: ensure that ResolveIPAddr(addr.String()) reproduces addr
Browse files Browse the repository at this point in the history
Updates golang#6465.

Change-Id: I5babbcf4c92dae47c823a41628b01e4ceb2332eb
Reviewed-on: https://go-review.googlesource.com/11951
Run-TryBot: Mikio Hara <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
cixtor committed Jul 10, 2015
1 parent a625b91 commit 7b5d536
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/net/ipraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var resolveIPAddrTests = []resolveIPAddrTest{
{"", "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

{"ip4:icmp", "", &IPAddr{}, nil},

{"l2tp", "127.0.0.1", nil, UnknownNetworkError("l2tp")},
{"l2tp:gre", "127.0.0.1", nil, UnknownNetworkError("l2tp:gre")},
{"tcp", "1.2.3.4:123", nil, UnknownNetworkError("tcp")},
Expand Down
5 changes: 3 additions & 2 deletions src/net/iprawsock.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ func (a *IPAddr) String() string {
if a == nil {
return "<nil>"
}
ip := ipEmptyString(a.IP)
if a.Zone != "" {
return a.IP.String() + "%" + a.Zone
return ip + "%" + a.Zone
}
return a.IP.String()
return ip
}

func (a *IPAddr) isWildcard() bool {
Expand Down

0 comments on commit 7b5d536

Please sign in to comment.