1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // IPAddr represents the address of an IP end point.
10 Zone
string // IPv6 scoped addressing zone
13 // Network returns the address's network name, "ip".
14 func (a
*IPAddr
) Network() string { return "ip" }
16 func (a
*IPAddr
) String() string {
21 return a
.IP
.String() + "%" + a
.Zone
26 func (a
*IPAddr
) toAddr() Addr
{
33 // ResolveIPAddr parses addr as an IP address of the form "host" or
34 // "ipv6-host%zone" and resolves the domain name on the network net,
35 // which must be "ip", "ip4" or "ip6".
36 func ResolveIPAddr(net
, addr
string) (*IPAddr
, error
) {
37 if net
== "" { // a hint wildcard for Go 1.0 undocumented behavior
40 afnet
, _
, err
:= parseNetwork(net
)
45 case "ip", "ip4", "ip6":
47 return nil, UnknownNetworkError(net
)
49 a
, err
:= resolveInternetAddr(afnet
, addr
, noDeadline
)
53 return a
.toAddr().(*IPAddr
), nil