diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 20:56:26 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 20:56:26 +0000 |
commit | df1304ee03f41aed179545d1e8b4684cfd22bbdf (patch) | |
tree | c68d6b2a9f5b82a23171b0a488a4b7e5c63ad860 /libgo/go/net/interface.go | |
parent | 3be18e47c33b61365786831e0f967f42b09922c9 (diff) | |
download | gcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.zip gcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.tar.gz gcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.tar.bz2 |
libgo: Update to weekly.2012-01-15.
From-SVN: r183539
Diffstat (limited to 'libgo/go/net/interface.go')
-rw-r--r-- | libgo/go/net/interface.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libgo/go/net/interface.go b/libgo/go/net/interface.go index 95486a6..5e7b352 100644 --- a/libgo/go/net/interface.go +++ b/libgo/go/net/interface.go @@ -12,6 +12,14 @@ import ( "fmt" ) +var ( + errInvalidInterface = errors.New("net: invalid interface") + errInvalidInterfaceIndex = errors.New("net: invalid interface index") + errInvalidInterfaceName = errors.New("net: invalid interface name") + errNoSuchInterface = errors.New("net: no such interface") + errNoSuchMulticastInterface = errors.New("net: no such multicast interface") +) + // A HardwareAddr represents a physical hardware address. type HardwareAddr []byte @@ -131,7 +139,7 @@ func (f Flags) String() string { // Addrs returns interface addresses for a specific interface. func (ifi *Interface) Addrs() ([]Addr, error) { if ifi == nil { - return nil, errors.New("net: invalid interface") + return nil, errInvalidInterface } return interfaceAddrTable(ifi.Index) } @@ -140,7 +148,7 @@ func (ifi *Interface) Addrs() ([]Addr, error) { // a specific interface. func (ifi *Interface) MulticastAddrs() ([]Addr, error) { if ifi == nil { - return nil, errors.New("net: invalid interface") + return nil, errInvalidInterface } return interfaceMulticastAddrTable(ifi.Index) } @@ -159,7 +167,7 @@ func InterfaceAddrs() ([]Addr, error) { // InterfaceByIndex returns the interface specified by index. func InterfaceByIndex(index int) (*Interface, error) { if index <= 0 { - return nil, errors.New("net: invalid interface index") + return nil, errInvalidInterfaceIndex } ift, err := interfaceTable(index) if err != nil { @@ -168,13 +176,13 @@ func InterfaceByIndex(index int) (*Interface, error) { for _, ifi := range ift { return &ifi, nil } - return nil, errors.New("net: no such interface") + return nil, errNoSuchInterface } // InterfaceByName returns the interface specified by name. func InterfaceByName(name string) (*Interface, error) { if name == "" { - return nil, errors.New("net: invalid interface name") + return nil, errInvalidInterfaceName } ift, err := interfaceTable(0) if err != nil { @@ -185,5 +193,5 @@ func InterfaceByName(name string) (*Interface, error) { return &ifi, nil } } - return nil, errors.New("net: no such interface") + return nil, errNoSuchInterface } |