diff options
Diffstat (limited to 'libgo/go/net')
62 files changed, 466 insertions, 512 deletions
diff --git a/libgo/go/net/cgo_stub.go b/libgo/go/net/cgo_stub.go index 565cbe7fece..fbe6150c26b 100644 --- a/libgo/go/net/cgo_stub.go +++ b/libgo/go/net/cgo_stub.go @@ -8,20 +8,18 @@ package net -import "os" - -func cgoLookupHost(name string) (addrs []string, err os.Error, completed bool) { +func cgoLookupHost(name string) (addrs []string, err error, completed bool) { return nil, nil, false } -func cgoLookupPort(network, service string) (port int, err os.Error, completed bool) { +func cgoLookupPort(network, service string) (port int, err error, completed bool) { return 0, nil, false } -func cgoLookupIP(name string) (addrs []IP, err os.Error, completed bool) { +func cgoLookupIP(name string) (addrs []IP, err error, completed bool) { return nil, nil, false } -func cgoLookupCNAME(name string) (cname string, err os.Error, completed bool) { +func cgoLookupCNAME(name string) (cname string, err error, completed bool) { return "", nil, false } diff --git a/libgo/go/net/cgo_unix.go b/libgo/go/net/cgo_unix.go index bfb3dfddff9..680d3e70b11 100644 --- a/libgo/go/net/cgo_unix.go +++ b/libgo/go/net/cgo_unix.go @@ -17,7 +17,6 @@ package net */ import ( - "os" "syscall" "unsafe" ) @@ -37,7 +36,7 @@ func bytePtrToString(p *byte) string { return string(a[:i]) } -func cgoLookupHost(name string) (addrs []string, err os.Error, completed bool) { +func cgoLookupHost(name string) (addrs []string, err error, completed bool) { ip, err, completed := cgoLookupIP(name) for _, p := range ip { addrs = append(addrs, p.String()) @@ -45,7 +44,7 @@ func cgoLookupHost(name string) (addrs []string, err os.Error, completed bool) { return } -func cgoLookupPort(net, service string) (port int, err os.Error, completed bool) { +func cgoLookupPort(net, service string) (port int, err error, completed bool) { var res *syscall.Addrinfo var hints syscall.Addrinfo @@ -91,7 +90,7 @@ func cgoLookupPort(net, service string) (port int, err os.Error, completed bool) return 0, &AddrError{"unknown port", net + "/" + service}, true } -func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err os.Error, completed bool) { +func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err error, completed bool) { var res *syscall.Addrinfo var hints syscall.Addrinfo @@ -114,7 +113,7 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err os.Error, comp } else { str = bytePtrToString(libc_gai_strerror(gerrno)) } - return nil, "", &DNSError{Error: str, Name: name}, true + return nil, "", &DNSError{Err: str, Name: name}, true } defer libc_freeaddrinfo(res) if res != nil { @@ -145,12 +144,12 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err os.Error, comp return addrs, cname, nil, true } -func cgoLookupIP(name string) (addrs []IP, err os.Error, completed bool) { +func cgoLookupIP(name string) (addrs []IP, err error, completed bool) { addrs, _, err, completed = cgoLookupIPCNAME(name) return } -func cgoLookupCNAME(name string) (cname string, err os.Error, completed bool) { +func cgoLookupCNAME(name string) (cname string, err error, completed bool) { _, cname, err, completed = cgoLookupIPCNAME(name) return } diff --git a/libgo/go/net/dial.go b/libgo/go/net/dial.go index 85d54b3703c..43866dcb51d 100644 --- a/libgo/go/net/dial.go +++ b/libgo/go/net/dial.go @@ -4,9 +4,7 @@ package net -import "os" - -func resolveNetAddr(op, net, addr string) (a Addr, err os.Error) { +func resolveNetAddr(op, net, addr string) (a Addr, err error) { if addr == "" { return nil, &OpError{op, net, nil, errMissingAddress} } @@ -44,7 +42,7 @@ func resolveNetAddr(op, net, addr string) (a Addr, err os.Error) { // Dial("tcp", "google.com:80") // Dial("tcp", "[de:ad:be:ef::ca:fe]:80") // -func Dial(net, addr string) (c Conn, err os.Error) { +func Dial(net, addr string) (c Conn, err error) { addri, err := resolveNetAddr("dial", net, addr) if err != nil { return nil, err @@ -70,7 +68,7 @@ func Dial(net, addr string) (c Conn, err os.Error) { // Listen announces on the local network address laddr. // The network string net must be a stream-oriented // network: "tcp", "tcp4", "tcp6", or "unix", or "unixpacket". -func Listen(net, laddr string) (l Listener, err os.Error) { +func Listen(net, laddr string) (l Listener, err error) { switch net { case "tcp", "tcp4", "tcp6": var la *TCPAddr @@ -103,7 +101,7 @@ func Listen(net, laddr string) (l Listener, err os.Error) { // ListenPacket announces on the local network address laddr. // The network string net must be a packet-oriented network: // "udp", "udp4", "udp6", or "unixgram". -func ListenPacket(net, laddr string) (c PacketConn, err os.Error) { +func ListenPacket(net, laddr string) (c PacketConn, err error) { switch net { case "udp", "udp4", "udp6": var la *UDPAddr diff --git a/libgo/go/net/dict/dict.go b/libgo/go/net/dict/dict.go index b146ea2123c..e7f5290f552 100644 --- a/libgo/go/net/dict/dict.go +++ b/libgo/go/net/dict/dict.go @@ -8,7 +8,6 @@ package dict import ( "net/textproto" - "os" "strconv" "strings" ) @@ -20,7 +19,7 @@ type Client struct { // Dial returns a new client connected to a dictionary server at // addr on the given network. -func Dial(network, addr string) (*Client, os.Error) { +func Dial(network, addr string) (*Client, error) { text, err := textproto.Dial(network, addr) if err != nil { return nil, err @@ -34,7 +33,7 @@ func Dial(network, addr string) (*Client, os.Error) { } // Close closes the connection to the dictionary server. -func (c *Client) Close() os.Error { +func (c *Client) Close() error { return c.text.Close() } @@ -45,7 +44,7 @@ type Dict struct { } // Dicts returns a list of the dictionaries available on the server. -func (c *Client) Dicts() ([]Dict, os.Error) { +func (c *Client) Dicts() ([]Dict, error) { id, err := c.text.Cmd("SHOW DB") if err != nil { return nil, err @@ -93,7 +92,7 @@ type Defn struct { // The special dictionary name "!" means to look in all the // server's dictionaries in turn, stopping after finding the word // in one of them. -func (c *Client) Define(dict, word string) ([]*Defn, os.Error) { +func (c *Client) Define(dict, word string) ([]*Defn, error) { id, err := c.text.Cmd("DEFINE %s %q", dict, word) if err != nil { return nil, err @@ -142,7 +141,7 @@ func (c *Client) Define(dict, word string) ([]*Defn, os.Error) { // Fields returns the fields in s. // Fields are space separated unquoted words // or quoted with single or double quote. -func fields(s string) ([]string, os.Error) { +func fields(s string) ([]string, error) { var v []string i := 0 for { diff --git a/libgo/go/net/dnsclient.go b/libgo/go/net/dnsclient.go index 93c04f6b590..e66f28c195c 100644 --- a/libgo/go/net/dnsclient.go +++ b/libgo/go/net/dnsclient.go @@ -7,20 +7,19 @@ package net import ( "bytes" "fmt" - "os" "rand" "sort" ) // DNSError represents a DNS lookup error. type DNSError struct { - Error string // description of the error + Err string // description of the error Name string // name looked for Server string // server used IsTimeout bool } -func (e *DNSError) String() string { +func (e *DNSError) Error() string { if e == nil { return "<nil>" } @@ -28,7 +27,7 @@ func (e *DNSError) String() string { if e.Server != "" { s += " on " + e.Server } - s += ": " + e.Error + s += ": " + e.Err return s } @@ -40,10 +39,10 @@ const noSuchHost = "no such host" // reverseaddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP // address addr suitable for rDNS (PTR) record lookup or an error if it fails // to parse the IP address. -func reverseaddr(addr string) (arpa string, err os.Error) { +func reverseaddr(addr string) (arpa string, err error) { ip := ParseIP(addr) if ip == nil { - return "", &DNSError{Error: "unrecognized address", Name: addr} + return "", &DNSError{Err: "unrecognized address", Name: addr} } if ip.To4() != nil { return fmt.Sprintf("%d.%d.%d.%d.in-addr.arpa.", ip[15], ip[14], ip[13], ip[12]), nil @@ -64,18 +63,18 @@ func reverseaddr(addr string) (arpa string, err os.Error) { // Find answer for name in dns message. // On return, if err == nil, addrs != nil. -func answer(name, server string, dns *dnsMsg, qtype uint16) (cname string, addrs []dnsRR, err os.Error) { +func answer(name, server string, dns *dnsMsg, qtype uint16) (cname string, addrs []dnsRR, err error) { addrs = make([]dnsRR, 0, len(dns.answer)) if dns.rcode == dnsRcodeNameError && dns.recursion_available { - return "", nil, &DNSError{Error: noSuchHost, Name: name} + return "", nil, &DNSError{Err: noSuchHost, Name: name} } if dns.rcode != dnsRcodeSuccess { // None of the error codes make sense // for the query we sent. If we didn't get // a name error and we didn't get success, // the server is behaving incorrectly. - return "", nil, &DNSError{Error: "server misbehaving", Name: name, Server: server} + return "", nil, &DNSError{Err: "server misbehaving", Name: name, Server: server} } // Look for the name. @@ -107,12 +106,12 @@ Cname: } } if len(addrs) == 0 { - return "", nil, &DNSError{Error: noSuchHost, Name: name, Server: server} + return "", nil, &DNSError{Err: noSuchHost, Name: name, Server: server} } return name, addrs, nil } - return "", nil, &DNSError{Error: "too many redirects", Name: name, Server: server} + return "", nil, &DNSError{Err: "too many redirects", Name: name, Server: server} } func isDomainName(s string) bool { diff --git a/libgo/go/net/dnsclient_unix.go b/libgo/go/net/dnsclient_unix.go index eb7db5e2707..e321ed9abef 100644 --- a/libgo/go/net/dnsclient_unix.go +++ b/libgo/go/net/dnsclient_unix.go @@ -17,7 +17,6 @@ package net import ( - "os" "rand" "sync" "time" @@ -25,9 +24,9 @@ import ( // Send a request on the connection and hope for a reply. // Up to cfg.attempts attempts. -func exchange(cfg *dnsConfig, c Conn, name string, qtype uint16) (*dnsMsg, os.Error) { +func exchange(cfg *dnsConfig, c Conn, name string, qtype uint16) (*dnsMsg, error) { if len(name) >= 256 { - return nil, &DNSError{Error: "name too long", Name: name} + return nil, &DNSError{Err: "name too long", Name: name} } out := new(dnsMsg) out.id = uint16(rand.Int()) ^ uint16(time.Nanoseconds()) @@ -37,7 +36,7 @@ func exchange(cfg *dnsConfig, c Conn, name string, qtype uint16) (*dnsMsg, os.Er out.recursion_desired = true msg, ok := out.Pack() if !ok { - return nil, &DNSError{Error: "internal error - cannot pack message", Name: name} + return nil, &DNSError{Err: "internal error - cannot pack message", Name: name} } for attempt := 0; attempt < cfg.attempts; attempt++ { @@ -67,14 +66,14 @@ func exchange(cfg *dnsConfig, c Conn, name string, qtype uint16) (*dnsMsg, os.Er if a := c.RemoteAddr(); a != nil { server = a.String() } - return nil, &DNSError{Error: "no answer from server", Name: name, Server: server, IsTimeout: true} + return nil, &DNSError{Err: "no answer from server", Name: name, Server: server, IsTimeout: true} } // Do a lookup for a single name, which must be rooted // (otherwise answer will not find the answers). -func tryOneName(cfg *dnsConfig, name string, qtype uint16) (cname string, addrs []dnsRR, err os.Error) { +func tryOneName(cfg *dnsConfig, name string, qtype uint16) (cname string, addrs []dnsRR, err error) { if len(cfg.servers) == 0 { - return "", nil, &DNSError{Error: "no DNS servers", Name: name} + return "", nil, &DNSError{Err: "no DNS servers", Name: name} } for i := 0; i < len(cfg.servers); i++ { // Calling Dial here is scary -- we have to be sure @@ -96,7 +95,7 @@ func tryOneName(cfg *dnsConfig, name string, qtype uint16) (cname string, addrs continue } cname, addrs, err = answer(name, server, msg, qtype) - if err == nil || err.(*DNSError).Error == noSuchHost { + if err == nil || err.(*DNSError).Err == noSuchHost { break } } @@ -123,15 +122,15 @@ func convertRR_AAAA(records []dnsRR) []IP { } var cfg *dnsConfig -var dnserr os.Error +var dnserr error func loadConfig() { cfg, dnserr = dnsReadConfig() } var onceLoadConfig sync.Once -func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err os.Error) { +func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err error) { if !isDomainName(name) { - return name, nil, &DNSError{Error: "invalid domain name", Name: name} + return name, nil, &DNSError{Err: "invalid domain name", Name: name} } onceLoadConfig.Do(loadConfig) if dnserr != nil || cfg == nil { @@ -186,7 +185,7 @@ func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err os.Erro // Normally we let cgo use the C library resolver instead of // depending on our lookup code, so that Go and C get the same // answers. -func goLookupHost(name string) (addrs []string, err os.Error) { +func goLookupHost(name string) (addrs []string, err error) { // Use entries from /etc/hosts if they match. addrs = lookupStaticHost(name) if len(addrs) > 0 { @@ -214,7 +213,7 @@ func goLookupHost(name string) (addrs []string, err os.Error) { // Normally we let cgo use the C library resolver instead of // depending on our lookup code, so that Go and C get the same // answers. -func goLookupIP(name string) (addrs []IP, err os.Error) { +func goLookupIP(name string) (addrs []IP, err error) { // Use entries from /etc/hosts if possible. haddrs := lookupStaticHost(name) if len(haddrs) > 0 { @@ -260,7 +259,7 @@ func goLookupIP(name string) (addrs []IP, err os.Error) { // Normally we let cgo use the C library resolver instead of // depending on our lookup code, so that Go and C get the same // answers. -func goLookupCNAME(name string) (cname string, err os.Error) { +func goLookupCNAME(name string) (cname string, err error) { onceLoadConfig.Do(loadConfig) if dnserr != nil || cfg == nil { err = dnserr diff --git a/libgo/go/net/dnsconfig.go b/libgo/go/net/dnsconfig.go index afc05991773..379fec95b86 100644 --- a/libgo/go/net/dnsconfig.go +++ b/libgo/go/net/dnsconfig.go @@ -8,8 +8,6 @@ package net -import "os" - type dnsConfig struct { servers []string // servers to use search []string // suffixes to append to local name @@ -19,14 +17,14 @@ type dnsConfig struct { rotate bool // round robin among servers } -var dnsconfigError os.Error +var dnsconfigError error type DNSConfigError struct { - Error os.Error + Err error } -func (e *DNSConfigError) String() string { - return "error reading DNS config: " + e.Error.String() +func (e *DNSConfigError) Error() string { + return "error reading DNS config: " + e.Err.Error() } func (e *DNSConfigError) Timeout() bool { return false } @@ -36,7 +34,7 @@ func (e *DNSConfigError) Temporary() bool { return false } // TODO(rsc): Supposed to call uname() and chop the beginning // of the host name to get the default search domain. // We assume it's in resolv.conf anyway. -func dnsReadConfig() (*dnsConfig, os.Error) { +func dnsReadConfig() (*dnsConfig, error) { file, err := open("/etc/resolv.conf") if err != nil { return nil, &DNSConfigError{err} diff --git a/libgo/go/net/fd.go b/libgo/go/net/fd.go index 80d40af7662..025075de48f 100644 --- a/libgo/go/net/fd.go +++ b/libgo/go/net/fd.go @@ -46,7 +46,7 @@ type netFD struct { type InvalidConnError struct{} -func (e *InvalidConnError) String() string { return "invalid net.Conn" } +func (e *InvalidConnError) Error() string { return "invalid net.Conn" } func (e *InvalidConnError) Temporary() bool { return false } func (e *InvalidConnError) Timeout() bool { return false } @@ -126,7 +126,7 @@ func (s *pollServer) AddFD(fd *netFD, mode int) { wake, err := s.poll.AddFD(intfd, mode, false) if err != nil { - panic("pollServer AddFD " + err.String()) + panic("pollServer AddFD " + err.Error()) } if wake { doWakeup = true @@ -227,7 +227,7 @@ func (s *pollServer) Run() { } fd, mode, err := s.poll.WaitFD(s, t) if err != nil { - print("pollServer WaitFD: ", err.String(), "\n") + print("pollServer WaitFD: ", err.Error(), "\n") return } if fd < 0 { @@ -271,12 +271,12 @@ var onceStartServer sync.Once func startServer() { p, err := newPollServer() if err != nil { - print("Start pollServer: ", err.String(), "\n") + print("Start pollServer: ", err.Error(), "\n") } pollserver = p } -func newFD(fd, family, proto int, net string) (f *netFD, err os.Error) { +func newFD(fd, family, proto int, net string) (f *netFD, err error) { onceStartServer.Do(startServer) if e := syscall.SetNonblock(fd, true); e != 0 { return nil, os.Errno(e) @@ -305,7 +305,7 @@ func (fd *netFD) setAddr(laddr, raddr Addr) { fd.sysfile = os.NewFile(fd.sysfd, fd.net+":"+ls+"->"+rs) } -func (fd *netFD) connect(ra syscall.Sockaddr) (err os.Error) { +func (fd *netFD) connect(ra syscall.Sockaddr) (err error) { e := syscall.Connect(fd.sysfd, ra) if e == syscall.EINPROGRESS { var errno int @@ -346,7 +346,7 @@ func (fd *netFD) decref() { fd.sysmu.Unlock() } -func (fd *netFD) Close() os.Error { +func (fd *netFD) Close() error { if fd == nil || fd.sysfile == nil { return os.EINVAL } @@ -358,7 +358,7 @@ func (fd *netFD) Close() os.Error { return nil } -func (fd *netFD) shutdown(how int) os.Error { +func (fd *netFD) shutdown(how int) error { if fd == nil || fd.sysfile == nil { return os.EINVAL } @@ -369,15 +369,15 @@ func (fd *netFD) shutdown(how int) os.Error { return nil } -func (fd *netFD) CloseRead() os.Error { +func (fd *netFD) CloseRead() error { return fd.shutdown(syscall.SHUT_RD) } -func (fd *netFD) CloseWrite() os.Error { +func (fd *netFD) CloseWrite() error { return fd.shutdown(syscall.SHUT_WR) } -func (fd *netFD) Read(p []byte) (n int, err os.Error) { +func (fd *netFD) Read(p []byte) (n int, err error) { if fd == nil { return 0, os.EINVAL } @@ -393,7 +393,7 @@ func (fd *netFD) Read(p []byte) (n int, err os.Error) { } else { fd.rdeadline = 0 } - var oserr os.Error + var oserr error for { var errno int n, errno = syscall.Read(fd.sysfile.Fd(), p) @@ -405,7 +405,7 @@ func (fd *netFD) Read(p []byte) (n int, err os.Error) { n = 0 oserr = os.Errno(errno) } else if n == 0 && errno == 0 && fd.proto != syscall.SOCK_DGRAM { - err = os.EOF + err = io.EOF } break } @@ -415,7 +415,7 @@ func (fd *netFD) Read(p []byte) (n int, err os.Error) { return } -func (fd *netFD) ReadFrom(p []byte) (n int, sa syscall.Sockaddr, err os.Error) { +func (fd *netFD) ReadFrom(p []byte) (n int, sa syscall.Sockaddr, err error) { if fd == nil || fd.sysfile == nil { return 0, nil, os.EINVAL } @@ -428,7 +428,7 @@ func (fd *netFD) ReadFrom(p []byte) (n int, sa syscall.Sockaddr, err os.Error) { } else { fd.rdeadline = 0 } - var oserr os.Error + var oserr error for { var errno int n, sa, errno = syscall.Recvfrom(fd.sysfd, p, 0) @@ -448,7 +448,7 @@ func (fd *netFD) ReadFrom(p []byte) (n int, sa syscall.Sockaddr, err os.Error) { return } -func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err os.Error) { +func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err error) { if fd == nil || fd.sysfile == nil { return 0, 0, 0, nil, os.EINVAL } @@ -461,7 +461,7 @@ func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S } else { fd.rdeadline = 0 } - var oserr os.Error + var oserr error for { var errno int n, oobn, flags, sa, errno = syscall.Recvmsg(fd.sysfd, p, oob, 0) @@ -473,7 +473,7 @@ func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S oserr = os.Errno(errno) } if n == 0 { - oserr = os.EOF + oserr = io.EOF } break } @@ -484,7 +484,7 @@ func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S return } -func (fd *netFD) Write(p []byte) (n int, err os.Error) { +func (fd *netFD) Write(p []byte) (n int, err error) { if fd == nil { return 0, os.EINVAL } @@ -501,7 +501,7 @@ func (fd *netFD) Write(p []byte) (n int, err os.Error) { fd.wdeadline = 0 } nn := 0 - var oserr os.Error + var oserr error for { n, errno := syscall.Write(fd.sysfile.Fd(), p[nn:]) @@ -531,7 +531,7 @@ func (fd *netFD) Write(p []byte) (n int, err os.Error) { return nn, err } -func (fd *netFD) WriteTo(p []byte, sa syscall.Sockaddr) (n int, err os.Error) { +func (fd *netFD) WriteTo(p []byte, sa syscall.Sockaddr) (n int, err error) { if fd == nil || fd.sysfile == nil { return 0, os.EINVAL } @@ -544,7 +544,7 @@ func (fd *netFD) WriteTo(p []byte, sa syscall.Sockaddr) (n int, err os.Error) { } else { fd.wdeadline = 0 } - var oserr os.Error + var oserr error for { errno := syscall.Sendto(fd.sysfd, p, 0, sa) if errno == syscall.EAGAIN && fd.wdeadline >= 0 { @@ -564,7 +564,7 @@ func (fd *netFD) WriteTo(p []byte, sa syscall.Sockaddr) (n int, err os.Error) { return } -func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err os.Error) { +func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error) { if fd == nil || fd.sysfile == nil { return 0, 0, os.EINVAL } @@ -577,7 +577,7 @@ func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oob } else { fd.wdeadline = 0 } - var oserr os.Error + var oserr error for { var errno int errno = syscall.Sendmsg(fd.sysfd, p, oob, sa, 0) @@ -599,7 +599,7 @@ func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oob return } -func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os.Error) { +func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err error) { if fd == nil || fd.sysfile == nil { return nil, os.EINVAL } @@ -647,7 +647,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os. return nfd, nil } -func (fd *netFD) dup() (f *os.File, err os.Error) { +func (fd *netFD) dup() (f *os.File, err error) { ns, e := syscall.Dup(fd.sysfd) if e != 0 { return nil, &OpError{"dup", fd.net, fd.laddr, os.Errno(e)} diff --git a/libgo/go/net/fd_linux.go b/libgo/go/net/fd_linux.go index c860c842af7..cce74cd6760 100644 --- a/libgo/go/net/fd_linux.go +++ b/libgo/go/net/fd_linux.go @@ -33,7 +33,7 @@ type pollster struct { ctlEvent syscall.EpollEvent } -func newpollster() (p *pollster, err os.Error) { +func newpollster() (p *pollster, err error) { p = new(pollster) var e int @@ -47,7 +47,7 @@ func newpollster() (p *pollster, err os.Error) { return p, nil } -func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, os.Error) { +func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, error) { // pollServer is locked. var already bool @@ -98,12 +98,12 @@ func (p *pollster) StopWaiting(fd int, bits uint) { p.ctlEvent.Fd = int32(fd) p.ctlEvent.Events = events if e := syscall.EpollCtl(p.epfd, syscall.EPOLL_CTL_MOD, fd, &p.ctlEvent); e != 0 { - print("Epoll modify fd=", fd, ": ", os.Errno(e).String(), "\n") + print("Epoll modify fd=", fd, ": ", os.Errno(e).Error(), "\n") } p.events[fd] = events } else { if e := syscall.EpollCtl(p.epfd, syscall.EPOLL_CTL_DEL, fd, nil); e != 0 { - print("Epoll delete fd=", fd, ": ", os.Errno(e).String(), "\n") + print("Epoll delete fd=", fd, ": ", os.Errno(e).Error(), "\n") } delete(p.events, fd) } @@ -130,7 +130,7 @@ func (p *pollster) DelFD(fd int, mode int) { } } -func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.Error) { +func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) { for len(p.waitEvents) == 0 { var msec int = -1 if nsec > 0 { @@ -177,6 +177,6 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E return fd, 'r', nil } -func (p *pollster) Close() os.Error { +func (p *pollster) Close() error { return os.NewSyscallError("close", syscall.Close(p.epfd)) } diff --git a/libgo/go/net/fd_openbsd.go b/libgo/go/net/fd_openbsd.go index e50883e940b..f61008a2fe1 100644 --- a/libgo/go/net/fd_openbsd.go +++ b/libgo/go/net/fd_openbsd.go @@ -21,7 +21,7 @@ type pollster struct { kbuf [1]syscall.Kevent_t } -func newpollster() (p *pollster, err os.Error) { +func newpollster() (p *pollster, err error) { p = new(pollster) var e int if p.kq, e = syscall.Kqueue(); e != 0 { @@ -31,7 +31,7 @@ func newpollster() (p *pollster, err os.Error) { return p, nil } -func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, os.Error) { +func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, error) { // pollServer is locked. var kmode int @@ -77,7 +77,7 @@ func (p *pollster) DelFD(fd int, mode int) { syscall.Kevent(p.kq, p.kbuf[:], nil, nil) } -func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.Error) { +func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) { var t *syscall.Timespec for len(p.events) == 0 { if nsec > 0 { @@ -113,4 +113,4 @@ func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.E return fd, mode, nil } -func (p *pollster) Close() os.Error { return os.NewSyscallError("close", syscall.Close(p.kq)) } +func (p *pollster) Close() error { return os.NewSyscallError("close", syscall.Close(p.kq)) } diff --git a/libgo/go/net/fd_windows.go b/libgo/go/net/fd_windows.go index 8e8b3b746d4..ce228e91edb 100644 --- a/libgo/go/net/fd_windows.go +++ b/libgo/go/net/fd_windows.go @@ -5,6 +5,7 @@ package net import ( + "io" "os" "runtime" "sync" @@ -15,11 +16,11 @@ import ( type InvalidConnError struct{} -func (e *InvalidConnError) String() string { return "invalid net.Conn" } +func (e *InvalidConnError) Error() string { return "invalid net.Conn" } func (e *InvalidConnError) Temporary() bool { return false } func (e *InvalidConnError) Timeout() bool { return false } -var initErr os.Error +var initErr error func init() { var d syscall.WSAData @@ -151,7 +152,7 @@ func (s *ioSrv) ProcessRemoteIO() { // ExecIO executes a single io operation. It either executes it // inline, or, if timeouts are employed, passes the request onto // a special goroutine and waits for completion or cancels request. -func (s *ioSrv) ExecIO(oi anOpIface, deadline_delta int64) (n int, err os.Error) { +func (s *ioSrv) ExecIO(oi anOpIface, deadline_delta int64) (n int, err error) { var e int o := oi.Op() if deadline_delta > 0 { @@ -249,7 +250,7 @@ func allocFD(fd syscall.Handle, family, proto int, net string) (f *netFD) { return f } -func newFD(fd syscall.Handle, family, proto int, net string) (f *netFD, err os.Error) { +func newFD(fd syscall.Handle, family, proto int, net string) (f *netFD, err error) { if initErr != nil { return nil, initErr } @@ -266,7 +267,7 @@ func (fd *netFD) setAddr(laddr, raddr Addr) { fd.raddr = raddr } -func (fd *netFD) connect(ra syscall.Sockaddr) (err os.Error) { +func (fd *netFD) connect(ra syscall.Sockaddr) (err error) { e := syscall.Connect(fd.sysfd, ra) if e != 0 { return os.Errno(e) @@ -300,7 +301,7 @@ func (fd *netFD) decref() { fd.sysmu.Unlock() } -func (fd *netFD) Close() os.Error { +func (fd *netFD) Close() error { if fd == nil || fd.sysfd == syscall.InvalidHandle { return os.EINVAL } @@ -312,7 +313,7 @@ func (fd *netFD) Close() os.Error { return nil } -func (fd *netFD) shutdown(how int) os.Error { +func (fd *netFD) shutdown(how int) error { if fd == nil || fd.sysfd == syscall.InvalidHandle { return os.EINVAL } @@ -323,11 +324,11 @@ func (fd *netFD) shutdown(how int) os.Error { return nil } -func (fd *netFD) CloseRead() os.Error { +func (fd *netFD) CloseRead() error { return fd.shutdown(syscall.SHUT_RD) } -func (fd *netFD) CloseWrite() os.Error { +func (fd *netFD) CloseWrite() error { return fd.shutdown(syscall.SHUT_WR) } @@ -346,7 +347,7 @@ func (o *readOp) Name() string { return "WSARecv" } -func (fd *netFD) Read(buf []byte) (n int, err os.Error) { +func (fd *netFD) Read(buf []byte) (n int, err error) { if fd == nil { return 0, os.EINVAL } @@ -361,7 +362,7 @@ func (fd *netFD) Read(buf []byte) (n int, err os.Error) { o.Init(fd, buf, 'r') n, err = iosrv.ExecIO(&o, fd.rdeadline_delta) if err == nil && n == 0 { - err = os.EOF + err = io.EOF } return } @@ -383,7 +384,7 @@ func (o *readFromOp) Name() string { return "WSARecvFrom" } -func (fd *netFD) ReadFrom(buf []byte) (n int, sa syscall.Sockaddr, err os.Error) { +func (fd *netFD) ReadFrom(buf []byte) (n int, sa syscall.Sockaddr, err error) { if fd == nil { return 0, nil, os.EINVAL } @@ -423,7 +424,7 @@ func (o *writeOp) Name() string { return "WSASend" } -func (fd *netFD) Write(buf []byte) (n int, err os.Error) { +func (fd *netFD) Write(buf []byte) (n int, err error) { if fd == nil { return 0, os.EINVAL } @@ -455,7 +456,7 @@ func (o *writeToOp) Name() string { return "WSASendto" } -func (fd *netFD) WriteTo(buf []byte, sa syscall.Sockaddr) (n int, err os.Error) { +func (fd *netFD) WriteTo(buf []byte, sa syscall.Sockaddr) (n int, err error) { if fd == nil { return 0, os.EINVAL } @@ -494,7 +495,7 @@ func (o *acceptOp) Name() string { return "AcceptEx" } -func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os.Error) { +func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err error) { if fd == nil || fd.sysfd == syscall.InvalidHandle { return nil, os.EINVAL } @@ -551,15 +552,15 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os. // Unimplemented functions. -func (fd *netFD) dup() (f *os.File, err os.Error) { +func (fd *netFD) dup() (f *os.File, err error) { // TODO: Implement this return nil, os.NewSyscallError("dup", syscall.EWINDOWS) } -func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err os.Error) { +func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err error) { return 0, 0, 0, nil, os.EAFNOSUPPORT } -func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err os.Error) { +func (fd *netFD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error) { return 0, 0, os.EAFNOSUPPORT } diff --git a/libgo/go/net/file.go b/libgo/go/net/file.go index ed2559d8c30..0ad869dbd57 100644 --- a/libgo/go/net/file.go +++ b/libgo/go/net/file.go @@ -11,7 +11,7 @@ import ( "syscall" ) -func newFileFD(f *os.File) (nfd *netFD, err os.Error) { +func newFileFD(f *os.File) (nfd *netFD, err error) { fd, errno := syscall.Dup(f.Fd()) if errno != 0 { return nil, os.NewSyscallError("dup", errno) @@ -67,7 +67,7 @@ func newFileFD(f *os.File) (nfd *netFD, err os.Error) { // the open file f. It is the caller's responsibility to close f when // finished. Closing c does not affect f, and closing f does not // affect c. -func FileConn(f *os.File) (c Conn, err os.Error) { +func FileConn(f *os.File) (c Conn, err error) { fd, err := newFileFD(f) if err != nil { return nil, err @@ -90,7 +90,7 @@ func FileConn(f *os.File) (c Conn, err os.Error) { // to the open file f. It is the caller's responsibility to close l // when finished. Closing c does not affect l, and closing l does not // affect c. -func FileListener(f *os.File) (l Listener, err os.Error) { +func FileListener(f *os.File) (l Listener, err error) { fd, err := newFileFD(f) if err != nil { return nil, err @@ -109,7 +109,7 @@ func FileListener(f *os.File) (l Listener, err os.Error) { // corresponding to the open file f. It is the caller's // responsibility to close f when finished. Closing c does not affect // f, and closing f does not affect c. -func FilePacketConn(f *os.File) (c PacketConn, err os.Error) { +func FilePacketConn(f *os.File) (c PacketConn, err error) { fd, err := newFileFD(f) if err != nil { return nil, err diff --git a/libgo/go/net/file_plan9.go b/libgo/go/net/file_plan9.go index a07e7433181..06d7cc89846 100644 --- a/libgo/go/net/file_plan9.go +++ b/libgo/go/net/file_plan9.go @@ -12,7 +12,7 @@ import ( // the open file f. It is the caller's responsibility to close f when // finished. Closing c does not affect f, and closing f does not // affect c. -func FileConn(f *os.File) (c Conn, err os.Error) { +func FileConn(f *os.File) (c Conn, err error) { return nil, os.EPLAN9 } @@ -20,7 +20,7 @@ func FileConn(f *os.File) (c Conn, err os.Error) { // to the open file f. It is the caller's responsibility to close l // when finished. Closing c does not affect l, and closing l does not // affect c. -func FileListener(f *os.File) (l Listener, err os.Error) { +func FileListener(f *os.File) (l Listener, err error) { return nil, os.EPLAN9 } @@ -28,6 +28,6 @@ func FileListener(f *os.File) (l Listener, err os.Error) { // corresponding to the open file f. It is the caller's // responsibility to close f when finished. Closing c does not affect // f, and closing f does not affect c. -func FilePacketConn(f *os.File) (c PacketConn, err os.Error) { +func FilePacketConn(f *os.File) (c PacketConn, err error) { return nil, os.EPLAN9 } diff --git a/libgo/go/net/file_test.go b/libgo/go/net/file_test.go index 0fa6740769b..7867fa8df36 100644 --- a/libgo/go/net/file_test.go +++ b/libgo/go/net/file_test.go @@ -14,17 +14,17 @@ import ( type listenerFile interface { Listener - File() (f *os.File, err os.Error) + File() (f *os.File, err error) } type packetConnFile interface { PacketConn - File() (f *os.File, err os.Error) + File() (f *os.File, err error) } type connFile interface { Conn - File() (f *os.File, err os.Error) + File() (f *os.File, err error) } func testFileListener(t *testing.T, net, laddr string) { diff --git a/libgo/go/net/file_windows.go b/libgo/go/net/file_windows.go index 94aa583755b..c50c32e2109 100644 --- a/libgo/go/net/file_windows.go +++ b/libgo/go/net/file_windows.go @@ -9,17 +9,17 @@ import ( "syscall" ) -func FileConn(f *os.File) (c Conn, err os.Error) { +func FileConn(f *os.File) (c Conn, err error) { // TODO: Implement this return nil, os.NewSyscallError("FileConn", syscall.EWINDOWS) } -func FileListener(f *os.File) (l Listener, err os.Error) { +func FileListener(f *os.File) (l Listener, err error) { // TODO: Implement this return nil, os.NewSyscallError("FileListener", syscall.EWINDOWS) } -func FilePacketConn(f *os.File) (c PacketConn, err os.Error) { +func FilePacketConn(f *os.File) (c PacketConn, err error) { // TODO: Implement this return nil, os.NewSyscallError("FilePacketConn", syscall.EWINDOWS) } diff --git a/libgo/go/net/interface.go b/libgo/go/net/interface.go index 2696b7f4c58..95486a6301e 100644 --- a/libgo/go/net/interface.go +++ b/libgo/go/net/interface.go @@ -8,8 +8,8 @@ package net import ( "bytes" + "errors" "fmt" - "os" ) // A HardwareAddr represents a physical hardware address. @@ -34,7 +34,7 @@ func (a HardwareAddr) String() string { // 01-23-45-67-89-ab-cd-ef // 0123.4567.89ab // 0123.4567.89ab.cdef -func ParseMAC(s string) (hw HardwareAddr, err os.Error) { +func ParseMAC(s string) (hw HardwareAddr, err error) { if len(s) < 14 { goto error } @@ -80,7 +80,7 @@ func ParseMAC(s string) (hw HardwareAddr, err os.Error) { return hw, nil error: - return nil, os.NewError("invalid MAC address: " + s) + return nil, errors.New("invalid MAC address: " + s) } // Interface represents a mapping between network interface name @@ -129,37 +129,37 @@ func (f Flags) String() string { } // Addrs returns interface addresses for a specific interface. -func (ifi *Interface) Addrs() ([]Addr, os.Error) { +func (ifi *Interface) Addrs() ([]Addr, error) { if ifi == nil { - return nil, os.NewError("net: invalid interface") + return nil, errors.New("net: invalid interface") } return interfaceAddrTable(ifi.Index) } // MulticastAddrs returns multicast, joined group addresses for // a specific interface. -func (ifi *Interface) MulticastAddrs() ([]Addr, os.Error) { +func (ifi *Interface) MulticastAddrs() ([]Addr, error) { if ifi == nil { - return nil, os.NewError("net: invalid interface") + return nil, errors.New("net: invalid interface") } return interfaceMulticastAddrTable(ifi.Index) } // Interfaces returns a list of the systems's network interfaces. -func Interfaces() ([]Interface, os.Error) { +func Interfaces() ([]Interface, error) { return interfaceTable(0) } // InterfaceAddrs returns a list of the system's network interface // addresses. -func InterfaceAddrs() ([]Addr, os.Error) { +func InterfaceAddrs() ([]Addr, error) { return interfaceAddrTable(0) } // InterfaceByIndex returns the interface specified by index. -func InterfaceByIndex(index int) (*Interface, os.Error) { +func InterfaceByIndex(index int) (*Interface, error) { if index <= 0 { - return nil, os.NewError("net: invalid interface index") + return nil, errors.New("net: invalid interface index") } ift, err := interfaceTable(index) if err != nil { @@ -168,13 +168,13 @@ func InterfaceByIndex(index int) (*Interface, os.Error) { for _, ifi := range ift { return &ifi, nil } - return nil, os.NewError("net: no such interface") + return nil, errors.New("net: no such interface") } // InterfaceByName returns the interface specified by name. -func InterfaceByName(name string) (*Interface, os.Error) { +func InterfaceByName(name string) (*Interface, error) { if name == "" { - return nil, os.NewError("net: invalid interface name") + return nil, errors.New("net: invalid interface name") } ift, err := interfaceTable(0) if err != nil { @@ -185,5 +185,5 @@ func InterfaceByName(name string) (*Interface, os.Error) { return &ifi, nil } } - return nil, os.NewError("net: no such interface") + return nil, errors.New("net: no such interface") } diff --git a/libgo/go/net/interface_bsd.go b/libgo/go/net/interface_bsd.go index 54fa5ddeb69..b026e01104d 100644 --- a/libgo/go/net/interface_bsd.go +++ b/libgo/go/net/interface_bsd.go @@ -17,7 +17,7 @@ import ( // If the ifindex is zero, interfaceTable returns mappings of all // network interfaces. Otheriwse it returns a mapping of a specific // interface. -func interfaceTable(ifindex int) ([]Interface, os.Error) { +func interfaceTable(ifindex int) ([]Interface, error) { var ( tab []byte e int @@ -51,7 +51,7 @@ func interfaceTable(ifindex int) ([]Interface, os.Error) { return ift, nil } -func newLink(m *syscall.InterfaceMessage) ([]Interface, os.Error) { +func newLink(m *syscall.InterfaceMessage) ([]Interface, error) { var ift []Interface sas, e := syscall.ParseRoutingSockaddr(m) @@ -107,7 +107,7 @@ func linkFlags(rawFlags int32) Flags { // If the ifindex is zero, interfaceAddrTable returns addresses // for all network interfaces. Otherwise it returns addresses // for a specific interface. -func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceAddrTable(ifindex int) ([]Addr, error) { var ( tab []byte e int @@ -141,7 +141,7 @@ func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { return ifat, nil } -func newAddr(m *syscall.InterfaceAddrMessage) ([]Addr, os.Error) { +func newAddr(m *syscall.InterfaceAddrMessage) ([]Addr, error) { var ifat []Addr sas, e := syscall.ParseRoutingSockaddr(m) diff --git a/libgo/go/net/interface_darwin.go b/libgo/go/net/interface_darwin.go index a7b68ad7f77..1472afb8846 100644 --- a/libgo/go/net/interface_darwin.go +++ b/libgo/go/net/interface_darwin.go @@ -14,7 +14,7 @@ import ( // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { var ( tab []byte e int @@ -48,7 +48,7 @@ func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { return ifmat, nil } -func newMulticastAddr(m *syscall.InterfaceMulticastAddrMessage) ([]Addr, os.Error) { +func newMulticastAddr(m *syscall.InterfaceMulticastAddrMessage) ([]Addr, error) { var ifmat []Addr sas, e := syscall.ParseRoutingSockaddr(m) diff --git a/libgo/go/net/interface_freebsd.go b/libgo/go/net/interface_freebsd.go index 20f506b08bc..b0274f68d75 100644 --- a/libgo/go/net/interface_freebsd.go +++ b/libgo/go/net/interface_freebsd.go @@ -14,7 +14,7 @@ import ( // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { var ( tab []byte e int @@ -48,7 +48,7 @@ func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { return ifmat, nil } -func newMulticastAddr(m *syscall.InterfaceMulticastAddrMessage) ([]Addr, os.Error) { +func newMulticastAddr(m *syscall.InterfaceMulticastAddrMessage) ([]Addr, error) { var ifmat []Addr sas, e := syscall.ParseRoutingSockaddr(m) diff --git a/libgo/go/net/interface_linux.go b/libgo/go/net/interface_linux.go index 36ae04ffa71..cd0339d61bd 100644 --- a/libgo/go/net/interface_linux.go +++ b/libgo/go/net/interface_linux.go @@ -16,7 +16,7 @@ import ( // If the ifindex is zero, interfaceTable returns mappings of all // network interfaces. Otheriwse it returns a mapping of a specific // interface. -func interfaceTable(ifindex int) ([]Interface, os.Error) { +func interfaceTable(ifindex int) ([]Interface, error) { var ( ift []Interface tab []byte @@ -101,11 +101,11 @@ func linkFlags(rawFlags uint32) Flags { // If the ifindex is zero, interfaceAddrTable returns addresses // for all network interfaces. Otherwise it returns addresses // for a specific interface. -func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceAddrTable(ifindex int) ([]Addr, error) { var ( tab []byte e int - err os.Error + err error ifat []Addr msgs []syscall.NetlinkMessage ) @@ -128,7 +128,7 @@ func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { return ifat, nil } -func addrTable(msgs []syscall.NetlinkMessage, ifindex int) ([]Addr, os.Error) { +func addrTable(msgs []syscall.NetlinkMessage, ifindex int) ([]Addr, error) { var ifat []Addr for _, m := range msgs { @@ -175,10 +175,10 @@ func newAddr(attrs []syscall.NetlinkRouteAttr, family int) []Addr { // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { var ( ifi *Interface - err os.Error + err error ) if ifindex > 0 { diff --git a/libgo/go/net/interface_openbsd.go b/libgo/go/net/interface_openbsd.go index f18149393a5..d8adb467653 100644 --- a/libgo/go/net/interface_openbsd.go +++ b/libgo/go/net/interface_openbsd.go @@ -6,11 +6,9 @@ package net -import "os" - // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { return nil, nil } diff --git a/libgo/go/net/interface_stub.go b/libgo/go/net/interface_stub.go index 282b38b5e49..4876b3af353 100644 --- a/libgo/go/net/interface_stub.go +++ b/libgo/go/net/interface_stub.go @@ -8,25 +8,23 @@ package net -import "os" - // If the ifindex is zero, interfaceTable returns mappings of all // network interfaces. Otheriwse it returns a mapping of a specific // interface. -func interfaceTable(ifindex int) ([]Interface, os.Error) { +func interfaceTable(ifindex int) ([]Interface, error) { return nil, nil } // If the ifindex is zero, interfaceAddrTable returns addresses // for all network interfaces. Otherwise it returns addresses // for a specific interface. -func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceAddrTable(ifindex int) ([]Addr, error) { return nil, nil } // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { return nil, nil } diff --git a/libgo/go/net/interface_test.go b/libgo/go/net/interface_test.go index c918f247f96..cc614910fac 100644 --- a/libgo/go/net/interface_test.go +++ b/libgo/go/net/interface_test.go @@ -6,7 +6,6 @@ package net import ( "bytes" - "os" "reflect" "strings" "testing" @@ -101,11 +100,11 @@ var mactests = []struct { {"0123.4567.89AB.CDEF", HardwareAddr{1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, ""}, } -func match(err os.Error, s string) bool { +func match(err error, s string) bool { if s == "" { return err == nil } - return err != nil && strings.Contains(err.String(), s) + return err != nil && strings.Contains(err.Error(), s) } func TestParseMAC(t *testing.T) { diff --git a/libgo/go/net/interface_windows.go b/libgo/go/net/interface_windows.go index 7f5169c8797..a1c8d95161c 100644 --- a/libgo/go/net/interface_windows.go +++ b/libgo/go/net/interface_windows.go @@ -21,7 +21,7 @@ func bytePtrToString(p *uint8) string { return string(a[:i]) } -func getAdapterList() (*syscall.IpAdapterInfo, os.Error) { +func getAdapterList() (*syscall.IpAdapterInfo, error) { b := make([]byte, 1000) l := uint32(len(b)) a := (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0])) @@ -37,7 +37,7 @@ func getAdapterList() (*syscall.IpAdapterInfo, os.Error) { return a, nil } -func getInterfaceList() ([]syscall.InterfaceInfo, os.Error) { +func getInterfaceList() ([]syscall.InterfaceInfo, error) { s, e := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPROTO_UDP) if e != 0 { return nil, os.NewSyscallError("Socket", e) @@ -58,7 +58,7 @@ func getInterfaceList() ([]syscall.InterfaceInfo, os.Error) { // If the ifindex is zero, interfaceTable returns mappings of all // network interfaces. Otheriwse it returns a mapping of a specific // interface. -func interfaceTable(ifindex int) ([]Interface, os.Error) { +func interfaceTable(ifindex int) ([]Interface, error) { ai, e := getAdapterList() if e != nil { return nil, e @@ -129,7 +129,7 @@ func interfaceTable(ifindex int) ([]Interface, os.Error) { // If the ifindex is zero, interfaceAddrTable returns addresses // for all network interfaces. Otherwise it returns addresses // for a specific interface. -func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceAddrTable(ifindex int) ([]Addr, error) { ai, e := getAdapterList() if e != nil { return nil, e @@ -153,6 +153,6 @@ func interfaceAddrTable(ifindex int) ([]Addr, os.Error) { // If the ifindex is zero, interfaceMulticastAddrTable returns // addresses for all network interfaces. Otherwise it returns // addresses for a specific interface. -func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { +func interfaceMulticastAddrTable(ifindex int) ([]Addr, error) { return nil, nil } diff --git a/libgo/go/net/ip.go b/libgo/go/net/ip.go index 61dc3be909c..4a388827875 100644 --- a/libgo/go/net/ip.go +++ b/libgo/go/net/ip.go @@ -12,8 +12,6 @@ package net -import "os" - // IP address lengths (bytes). const ( IPv4len = 4 @@ -594,7 +592,7 @@ type ParseError struct { Text string } -func (e *ParseError) String() string { +func (e *ParseError) Error() string { return "invalid " + e.Type + ": " + e.Text } @@ -627,7 +625,7 @@ func ParseIP(s string) IP { // It returns the IP address and the network implied by the IP // and mask. For example, ParseCIDR("192.168.100.1/16") returns // the IP address 192.168.100.1 and the network 192.168.0.0/16. -func ParseCIDR(s string) (IP, *IPNet, os.Error) { +func ParseCIDR(s string) (IP, *IPNet, error) { i := byteIndex(s, '/') if i < 0 { return nil, nil, &ParseError{"CIDR address", s} diff --git a/libgo/go/net/ip_test.go b/libgo/go/net/ip_test.go index 07e627aef4f..0ca315e7c07 100644 --- a/libgo/go/net/ip_test.go +++ b/libgo/go/net/ip_test.go @@ -8,7 +8,6 @@ import ( "bytes" "reflect" "testing" - "os" "runtime" ) @@ -113,7 +112,7 @@ var parsecidrtests = []struct { in string ip IP net *IPNet - err os.Error + err error }{ {"135.104.0.0/32", IPv4(135, 104, 0, 0), &IPNet{IPv4(135, 104, 0, 0), IPv4Mask(255, 255, 255, 255)}, nil}, {"0.0.0.0/24", IPv4(0, 0, 0, 0), &IPNet{IPv4(0, 0, 0, 0), IPv4Mask(255, 255, 255, 0)}, nil}, diff --git a/libgo/go/net/ipraw_test.go b/libgo/go/net/ipraw_test.go index 6894ce656dd..60c405ab4ac 100644 --- a/libgo/go/net/ipraw_test.go +++ b/libgo/go/net/ipraw_test.go @@ -71,7 +71,7 @@ func TestICMP(t *testing.T) { var ( laddr *IPAddr - err os.Error + err error ) if *srchost != "" { laddr, err = ResolveIPAddr("ip4", *srchost) diff --git a/libgo/go/net/iprawsock.go b/libgo/go/net/iprawsock.go index 662b9f57bd3..b23213ee191 100644 --- a/libgo/go/net/iprawsock.go +++ b/libgo/go/net/iprawsock.go @@ -6,10 +6,6 @@ package net -import ( - "os" -) - // IPAddr represents the address of a IP end point. type IPAddr struct { IP IP @@ -29,7 +25,7 @@ func (a *IPAddr) String() string { // names to numeric addresses on the network net, which must be // "ip", "ip4" or "ip6". A literal IPv6 host address must be // enclosed in square brackets, as in "[::]". -func ResolveIPAddr(net, addr string) (*IPAddr, os.Error) { +func ResolveIPAddr(net, addr string) (*IPAddr, error) { ip, err := hostToIP(net, addr) if err != nil { return nil, err @@ -38,7 +34,7 @@ func ResolveIPAddr(net, addr string) (*IPAddr, os.Error) { } // Convert "host" into IP address. -func hostToIP(net, host string) (ip IP, err os.Error) { +func hostToIP(net, host string) (ip IP, err error) { var addr IP // Try as an IP address. addr = ParseIP(host) diff --git a/libgo/go/net/iprawsock_plan9.go b/libgo/go/net/iprawsock_plan9.go index 808e17974f8..7e4bc56faca 100644 --- a/libgo/go/net/iprawsock_plan9.go +++ b/libgo/go/net/iprawsock_plan9.go @@ -17,17 +17,17 @@ type IPConn bool // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *IPConn) Read(b []byte) (n int, err os.Error) { +func (c *IPConn) Read(b []byte) (n int, err error) { return 0, os.EPLAN9 } // Write implements the net.Conn Write method. -func (c *IPConn) Write(b []byte) (n int, err os.Error) { +func (c *IPConn) Write(b []byte) (n int, err error) { return 0, os.EPLAN9 } // Close closes the IP connection. -func (c *IPConn) Close() os.Error { +func (c *IPConn) Close() error { return os.EPLAN9 } @@ -42,24 +42,24 @@ func (c *IPConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *IPConn) SetTimeout(nsec int64) os.Error { +func (c *IPConn) SetTimeout(nsec int64) error { return os.EPLAN9 } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *IPConn) SetReadTimeout(nsec int64) os.Error { +func (c *IPConn) SetReadTimeout(nsec int64) error { return os.EPLAN9 } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *IPConn) SetWriteTimeout(nsec int64) os.Error { +func (c *IPConn) SetWriteTimeout(nsec int64) error { return os.EPLAN9 } // IP-specific methods. // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err error) { err = os.EPLAN9 return } @@ -70,23 +70,23 @@ func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. -func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (n int, err os.Error) { +func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (n int, err error) { return 0, os.EPLAN9 } // WriteTo implements the net.PacketConn WriteTo method. -func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err error) { return 0, os.EPLAN9 } -func splitNetProto(netProto string) (net string, proto int, err os.Error) { +func splitNetProto(netProto string) (net string, proto int, err error) { err = os.EPLAN9 return } // DialIP connects to the remote address raddr on the network net, // which must be "ip", "ip4", or "ip6". -func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err os.Error) { +func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err error) { return nil, os.EPLAN9 } @@ -94,6 +94,6 @@ func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err os.Error) { // local address laddr. The returned connection c's ReadFrom // and WriteTo methods can be used to receive and send IP // packets with per-packet addressing. -func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err os.Error) { +func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err error) { return nil, os.EPLAN9 } diff --git a/libgo/go/net/iprawsock_posix.go b/libgo/go/net/iprawsock_posix.go index dafbdab7804..3bb99f9a577 100644 --- a/libgo/go/net/iprawsock_posix.go +++ b/libgo/go/net/iprawsock_posix.go @@ -9,6 +9,7 @@ package net import ( + "errors" "os" "syscall" ) @@ -33,7 +34,7 @@ func (a *IPAddr) family() int { return syscall.AF_INET6 } -func (a *IPAddr) sockaddr(family int) (syscall.Sockaddr, os.Error) { +func (a *IPAddr) sockaddr(family int) (syscall.Sockaddr, error) { return ipToSockaddr(family, a.IP, 0) } @@ -57,13 +58,13 @@ func (c *IPConn) ok() bool { return c != nil && c.fd != nil } // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *IPConn) Read(b []byte) (n int, err os.Error) { +func (c *IPConn) Read(b []byte) (n int, err error) { n, _, err = c.ReadFrom(b) return } // Write implements the net.Conn Write method. -func (c *IPConn) Write(b []byte) (n int, err os.Error) { +func (c *IPConn) Write(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -71,7 +72,7 @@ func (c *IPConn) Write(b []byte) (n int, err os.Error) { } // Close closes the IP connection. -func (c *IPConn) Close() os.Error { +func (c *IPConn) Close() error { if !c.ok() { return os.EINVAL } @@ -97,7 +98,7 @@ func (c *IPConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *IPConn) SetTimeout(nsec int64) os.Error { +func (c *IPConn) SetTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -105,7 +106,7 @@ func (c *IPConn) SetTimeout(nsec int64) os.Error { } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *IPConn) SetReadTimeout(nsec int64) os.Error { +func (c *IPConn) SetReadTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -113,7 +114,7 @@ func (c *IPConn) SetReadTimeout(nsec int64) os.Error { } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *IPConn) SetWriteTimeout(nsec int64) os.Error { +func (c *IPConn) SetWriteTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -122,7 +123,7 @@ func (c *IPConn) SetWriteTimeout(nsec int64) os.Error { // SetReadBuffer sets the size of the operating system's // receive buffer associated with the connection. -func (c *IPConn) SetReadBuffer(bytes int) os.Error { +func (c *IPConn) SetReadBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -131,7 +132,7 @@ func (c *IPConn) SetReadBuffer(bytes int) os.Error { // SetWriteBuffer sets the size of the operating system's // transmit buffer associated with the connection. -func (c *IPConn) SetWriteBuffer(bytes int) os.Error { +func (c *IPConn) SetWriteBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -147,7 +148,7 @@ func (c *IPConn) SetWriteBuffer(bytes int) os.Error { // ReadFromIP can be made to time out and return an error with // Timeout() == true after a fixed time limit; see SetTimeout and // SetReadTimeout. -func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err os.Error) { +func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -169,7 +170,7 @@ func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err os.Error) { } // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -183,19 +184,19 @@ func (c *IPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. -func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (n int, err os.Error) { +func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } sa, err1 := addr.sockaddr(c.fd.family) if err1 != nil { - return 0, &OpError{Op: "write", Net: "ip", Addr: addr, Error: err1} + return 0, &OpError{Op: "write", Net: "ip", Addr: addr, Err: err1} } return c.fd.WriteTo(b, sa) } // WriteTo implements the net.PacketConn WriteTo method. -func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -206,10 +207,10 @@ func (c *IPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { return c.WriteToIP(b, a) } -func splitNetProto(netProto string) (net string, proto int, err os.Error) { +func splitNetProto(netProto string) (net string, proto int, err error) { i := last(netProto, ':') if i < 0 { // no colon - return "", 0, os.NewError("no IP protocol specified") + return "", 0, errors.New("no IP protocol specified") } net = netProto[0:i] protostr := netProto[i+1:] @@ -225,7 +226,7 @@ func splitNetProto(netProto string) (net string, proto int, err os.Error) { // DialIP connects to the remote address raddr on the network net, // which must be "ip", "ip4", or "ip6". -func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err os.Error) { +func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err error) { net, proto, err := splitNetProto(netProto) if err != nil { return @@ -249,7 +250,7 @@ func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err os.Error) { // local address laddr. The returned connection c's ReadFrom // and WriteTo methods can be used to receive and send IP // packets with per-packet addressing. -func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err os.Error) { +func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err error) { net, proto, err := splitNetProto(netProto) if err != nil { return @@ -267,7 +268,7 @@ func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err os.Error) { } // BindToDevice binds an IPConn to a network interface. -func (c *IPConn) BindToDevice(device string) os.Error { +func (c *IPConn) BindToDevice(device string) error { if !c.ok() { return os.EINVAL } @@ -279,4 +280,4 @@ func (c *IPConn) BindToDevice(device string) os.Error { // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (c *IPConn) File() (f *os.File, err os.Error) { return c.fd.dup() } +func (c *IPConn) File() (f *os.File, err error) { return c.fd.dup() } diff --git a/libgo/go/net/ipsock.go b/libgo/go/net/ipsock.go index 4e2a5622b36..716454d8a98 100644 --- a/libgo/go/net/ipsock.go +++ b/libgo/go/net/ipsock.go @@ -6,10 +6,6 @@ package net -import ( - "os" -) - var supportsIPv6, supportsIPv4map = probeIPv6Stack() func firstFavoriteAddr(filter func(IP) IP, addrs []string) (addr IP) { @@ -61,14 +57,14 @@ func ipv6only(x IP) IP { type InvalidAddrError string -func (e InvalidAddrError) String() string { return string(e) } +func (e InvalidAddrError) Error() string { return string(e) } func (e InvalidAddrError) Timeout() bool { return false } func (e InvalidAddrError) Temporary() bool { return false } // SplitHostPort splits a network address of the form // "host:port" or "[host]:port" into host and port. // The latter form must be used when host contains a colon. -func SplitHostPort(hostport string) (host, port string, err os.Error) { +func SplitHostPort(hostport string) (host, port string, err error) { // The port starts after the last colon. i := last(hostport, ':') if i < 0 { @@ -102,7 +98,7 @@ func JoinHostPort(host, port string) string { } // Convert "host:port" into IP address and port. -func hostPortToIP(net, hostport string) (ip IP, iport int, err os.Error) { +func hostPortToIP(net, hostport string) (ip IP, iport int, err error) { var ( addr IP p, i int diff --git a/libgo/go/net/ipsock_plan9.go b/libgo/go/net/ipsock_plan9.go index 9e5da6d38a7..42fb408041a 100644 --- a/libgo/go/net/ipsock_plan9.go +++ b/libgo/go/net/ipsock_plan9.go @@ -7,6 +7,8 @@ package net import ( + "errors" + "io" "os" ) @@ -18,7 +20,7 @@ func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) { } // parsePlan9Addr parses address of the form [ip!]port (e.g. 127.0.0.1!80). -func parsePlan9Addr(s string) (ip IP, iport int, err os.Error) { +func parsePlan9Addr(s string) (ip IP, iport int, err error) { var ( addr IP p, i int @@ -29,13 +31,13 @@ func parsePlan9Addr(s string) (ip IP, iport int, err os.Error) { if i >= 0 { addr = ParseIP(s[:i]) if addr == nil { - err = os.NewError("net: parsing IP failed") + err = errors.New("net: parsing IP failed") goto Error } } p, _, ok = dtoi(s[i+1:], 0) if !ok { - err = os.NewError("net: parsing port failed") + err = errors.New("net: parsing port failed") goto Error } if p < 0 || p > 0xFFFF { @@ -48,7 +50,7 @@ Error: return nil, 0, err } -func readPlan9Addr(proto, filename string) (addr Addr, err os.Error) { +func readPlan9Addr(proto, filename string) (addr Addr, err error) { var buf [128]byte f, err := os.Open(filename) @@ -69,7 +71,7 @@ func readPlan9Addr(proto, filename string) (addr Addr, err os.Error) { case "udp": addr = &UDPAddr{ip, port} default: - return nil, os.NewError("unknown protocol " + proto) + return nil, errors.New("unknown protocol " + proto) } return addr, nil } @@ -89,7 +91,7 @@ func (c *plan9Conn) ok() bool { return c != nil && c.ctl != nil } // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *plan9Conn) Read(b []byte) (n int, err os.Error) { +func (c *plan9Conn) Read(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -100,7 +102,7 @@ func (c *plan9Conn) Read(b []byte) (n int, err os.Error) { } } n, err = c.data.Read(b) - if c.proto == "udp" && err == os.EOF { + if c.proto == "udp" && err == io.EOF { n = 0 err = nil } @@ -108,7 +110,7 @@ func (c *plan9Conn) Read(b []byte) (n int, err os.Error) { } // Write implements the net.Conn Write method. -func (c *plan9Conn) Write(b []byte) (n int, err os.Error) { +func (c *plan9Conn) Write(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -122,7 +124,7 @@ func (c *plan9Conn) Write(b []byte) (n int, err os.Error) { } // Close closes the connection. -func (c *plan9Conn) Close() os.Error { +func (c *plan9Conn) Close() error { if !c.ok() { return os.EINVAL } @@ -155,7 +157,7 @@ func (c *plan9Conn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *plan9Conn) SetTimeout(nsec int64) os.Error { +func (c *plan9Conn) SetTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -163,7 +165,7 @@ func (c *plan9Conn) SetTimeout(nsec int64) os.Error { } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *plan9Conn) SetReadTimeout(nsec int64) os.Error { +func (c *plan9Conn) SetReadTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -171,14 +173,14 @@ func (c *plan9Conn) SetReadTimeout(nsec int64) os.Error { } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *plan9Conn) SetWriteTimeout(nsec int64) os.Error { +func (c *plan9Conn) SetWriteTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } return os.EPLAN9 } -func startPlan9(net string, addr Addr) (ctl *os.File, dest, proto, name string, err os.Error) { +func startPlan9(net string, addr Addr) (ctl *os.File, dest, proto, name string, err error) { var ( ip IP port int @@ -213,7 +215,7 @@ func startPlan9(net string, addr Addr) (ctl *os.File, dest, proto, name string, return f, dest, proto, string(buf[:n]), nil } -func dialPlan9(net string, laddr, raddr Addr) (c *plan9Conn, err os.Error) { +func dialPlan9(net string, laddr, raddr Addr) (c *plan9Conn, err error) { f, dest, proto, name, err := startPlan9(net, raddr) if err != nil { return @@ -239,7 +241,7 @@ type plan9Listener struct { laddr Addr } -func listenPlan9(net string, laddr Addr) (l *plan9Listener, err os.Error) { +func listenPlan9(net string, laddr Addr) (l *plan9Listener, err error) { f, dest, proto, name, err := startPlan9(net, laddr) if err != nil { return @@ -265,7 +267,7 @@ func (l *plan9Listener) plan9Conn() *plan9Conn { return newPlan9Conn(l.proto, l.name, l.ctl, l.laddr, nil) } -func (l *plan9Listener) acceptPlan9() (c *plan9Conn, err os.Error) { +func (l *plan9Listener) acceptPlan9() (c *plan9Conn, err error) { f, err := os.Open(l.dir + "/listen") if err != nil { return @@ -287,7 +289,7 @@ func (l *plan9Listener) acceptPlan9() (c *plan9Conn, err os.Error) { return newPlan9Conn(l.proto, name, f, laddr, raddr), nil } -func (l *plan9Listener) Accept() (c Conn, err os.Error) { +func (l *plan9Listener) Accept() (c Conn, err error) { c1, err := l.acceptPlan9() if err != nil { return @@ -295,7 +297,7 @@ func (l *plan9Listener) Accept() (c Conn, err os.Error) { return c1, nil } -func (l *plan9Listener) Close() os.Error { +func (l *plan9Listener) Close() error { if l == nil || l.ctl == nil { return os.EINVAL } diff --git a/libgo/go/net/ipsock_posix.go b/libgo/go/net/ipsock_posix.go index 049df9ea4cb..d5b8f2189c4 100644 --- a/libgo/go/net/ipsock_posix.go +++ b/libgo/go/net/ipsock_posix.go @@ -6,10 +6,7 @@ package net -import ( - "os" - "syscall" -) +import "syscall" // Should we try to use the IPv4 socket interface if we're // only dealing with IPv4 sockets? As long as the host system @@ -105,12 +102,12 @@ func listenBacklog() int { return syscall.SOMAXCONN } // be converted into a syscall.Sockaddr. type sockaddr interface { Addr - sockaddr(family int) (syscall.Sockaddr, os.Error) + sockaddr(family int) (syscall.Sockaddr, error) family() int } -func internetSocket(net string, laddr, raddr sockaddr, socktype, proto int, mode string, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err os.Error) { - var oserr os.Error +func internetSocket(net string, laddr, raddr sockaddr, socktype, proto int, mode string, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err error) { + var oserr error var la, ra syscall.Sockaddr family := favoriteAddrFamily(net, raddr, laddr, mode) if laddr != nil { @@ -137,7 +134,7 @@ Error: return nil, &OpError{mode, net, addr, oserr} } -func ipToSockaddr(family int, ip IP, port int) (syscall.Sockaddr, os.Error) { +func ipToSockaddr(family int, ip IP, port int) (syscall.Sockaddr, error) { switch family { case syscall.AF_INET: if len(ip) == 0 { diff --git a/libgo/go/net/lookup_plan9.go b/libgo/go/net/lookup_plan9.go index a14c592e8f6..027794a5e4b 100644 --- a/libgo/go/net/lookup_plan9.go +++ b/libgo/go/net/lookup_plan9.go @@ -5,10 +5,11 @@ package net import ( + "errors" "os" ) -func query(filename, query string, bufSize int) (res []string, err os.Error) { +func query(filename, query string, bufSize int) (res []string, err error) { file, err := os.OpenFile(filename, os.O_RDWR, 0) if err != nil { return @@ -34,7 +35,7 @@ func query(filename, query string, bufSize int) (res []string, err os.Error) { return } -func queryCS(net, host, service string) (res []string, err os.Error) { +func queryCS(net, host, service string) (res []string, err error) { switch net { case "tcp4", "tcp6": net = "tcp" @@ -47,7 +48,7 @@ func queryCS(net, host, service string) (res []string, err os.Error) { return query("/net/cs", net+"!"+host+"!"+service, 128) } -func queryCS1(net string, ip IP, port int) (clone, dest string, err os.Error) { +func queryCS1(net string, ip IP, port int) (clone, dest string, err error) { ips := "*" if len(ip) != 0 && !ip.IsUnspecified() { ips = ip.String() @@ -58,19 +59,19 @@ func queryCS1(net string, ip IP, port int) (clone, dest string, err os.Error) { } f := getFields(lines[0]) if len(f) < 2 { - return "", "", os.NewError("net: bad response from ndb/cs") + return "", "", errors.New("net: bad response from ndb/cs") } clone, dest = f[0], f[1] return } -func queryDNS(addr string, typ string) (res []string, err os.Error) { +func queryDNS(addr string, typ string) (res []string, err error) { return query("/net/dns", addr+" "+typ, 1024) } // LookupHost looks up the given host using the local resolver. // It returns an array of that host's addresses. -func LookupHost(host string) (addrs []string, err os.Error) { +func LookupHost(host string) (addrs []string, err error) { // Use /net/cs insead of /net/dns because cs knows about // host names in local network (e.g. from /lib/ndb/local) lines, err := queryCS("tcp", host, "1") @@ -96,7 +97,7 @@ func LookupHost(host string) (addrs []string, err os.Error) { // LookupIP looks up host using the local resolver. // It returns an array of that host's IPv4 and IPv6 addresses. -func LookupIP(host string) (ips []IP, err os.Error) { +func LookupIP(host string) (ips []IP, err error) { addrs, err := LookupHost(host) if err != nil { return @@ -110,7 +111,7 @@ func LookupIP(host string) (ips []IP, err os.Error) { } // LookupPort looks up the port for the given network and service. -func LookupPort(network, service string) (port int, err os.Error) { +func LookupPort(network, service string) (port int, err error) { switch network { case "tcp4", "tcp6": network = "tcp" @@ -143,7 +144,7 @@ func LookupPort(network, service string) (port int, err os.Error) { // Callers that do not care about the canonical name can call // LookupHost or LookupIP directly; both take care of resolving // the canonical name as part of the lookup. -func LookupCNAME(name string) (cname string, err os.Error) { +func LookupCNAME(name string) (cname string, err error) { lines, err := queryDNS(name, "cname") if err != nil { return @@ -153,7 +154,7 @@ func LookupCNAME(name string) (cname string, err os.Error) { return f[2] + ".", nil } } - return "", os.NewError("net: bad response from ndb/dns") + return "", errors.New("net: bad response from ndb/dns") } // LookupSRV tries to resolve an SRV query of the given service, @@ -165,7 +166,7 @@ func LookupCNAME(name string) (cname string, err os.Error) { // That is, it looks up _service._proto.name. To accommodate services // publishing SRV records under non-standard names, if both service // and proto are empty strings, LookupSRV looks up name directly. -func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os.Error) { +func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) { var target string if service == "" && proto == "" { target = name @@ -195,7 +196,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os. } // LookupMX returns the DNS MX records for the given domain name sorted by preference. -func LookupMX(name string) (mx []*MX, err os.Error) { +func LookupMX(name string) (mx []*MX, err error) { lines, err := queryDNS(name, "mx") if err != nil { return @@ -214,7 +215,7 @@ func LookupMX(name string) (mx []*MX, err os.Error) { } // LookupTXT returns the DNS TXT records for the given domain name. -func LookupTXT(name string) (txt []string, err os.Error) { +func LookupTXT(name string) (txt []string, err error) { lines, err := queryDNS(name, "txt") if err != nil { return @@ -229,7 +230,7 @@ func LookupTXT(name string) (txt []string, err os.Error) { // LookupAddr performs a reverse lookup for the given address, returning a list // of names mapping to that address. -func LookupAddr(addr string) (name []string, err os.Error) { +func LookupAddr(addr string) (name []string, err error) { arpa, err := reverseaddr(addr) if err != nil { return diff --git a/libgo/go/net/lookup_unix.go b/libgo/go/net/lookup_unix.go index 6e79295a948..aae6d6ceb95 100644 --- a/libgo/go/net/lookup_unix.go +++ b/libgo/go/net/lookup_unix.go @@ -7,7 +7,7 @@ package net import ( - "os" + "errors" "sync" ) @@ -43,18 +43,18 @@ func readProtocols() { // lookupProtocol looks up IP protocol name in /etc/protocols and // returns correspondent protocol number. -func lookupProtocol(name string) (proto int, err os.Error) { +func lookupProtocol(name string) (proto int, err error) { onceReadProtocols.Do(readProtocols) proto, found := protocols[name] if !found { - return 0, os.NewError("unknown IP protocol specified: " + name) + return 0, errors.New("unknown IP protocol specified: " + name) } return } // LookupHost looks up the given host using the local resolver. // It returns an array of that host's addresses. -func LookupHost(host string) (addrs []string, err os.Error) { +func LookupHost(host string) (addrs []string, err error) { addrs, err, ok := cgoLookupHost(host) if !ok { addrs, err = goLookupHost(host) @@ -64,7 +64,7 @@ func LookupHost(host string) (addrs []string, err os.Error) { // LookupIP looks up host using the local resolver. // It returns an array of that host's IPv4 and IPv6 addresses. -func LookupIP(host string) (addrs []IP, err os.Error) { +func LookupIP(host string) (addrs []IP, err error) { addrs, err, ok := cgoLookupIP(host) if !ok { addrs, err = goLookupIP(host) @@ -73,7 +73,7 @@ func LookupIP(host string) (addrs []IP, err os.Error) { } // LookupPort looks up the port for the given network and service. -func LookupPort(network, service string) (port int, err os.Error) { +func LookupPort(network, service string) (port int, err error) { port, err, ok := cgoLookupPort(network, service) if !ok { port, err = goLookupPort(network, service) @@ -85,7 +85,7 @@ func LookupPort(network, service string) (port int, err os.Error) { // Callers that do not care about the canonical name can call // LookupHost or LookupIP directly; both take care of resolving // the canonical name as part of the lookup. -func LookupCNAME(name string) (cname string, err os.Error) { +func LookupCNAME(name string) (cname string, err error) { cname, err, ok := cgoLookupCNAME(name) if !ok { cname, err = goLookupCNAME(name) @@ -102,7 +102,7 @@ func LookupCNAME(name string) (cname string, err os.Error) { // That is, it looks up _service._proto.name. To accommodate services // publishing SRV records under non-standard names, if both service // and proto are empty strings, LookupSRV looks up name directly. -func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os.Error) { +func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) { var target string if service == "" && proto == "" { target = name @@ -124,7 +124,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os. } // LookupMX returns the DNS MX records for the given domain name sorted by preference. -func LookupMX(name string) (mx []*MX, err os.Error) { +func LookupMX(name string) (mx []*MX, err error) { _, records, err := lookup(name, dnsTypeMX) if err != nil { return @@ -139,7 +139,7 @@ func LookupMX(name string) (mx []*MX, err os.Error) { } // LookupTXT returns the DNS TXT records for the given domain name. -func LookupTXT(name string) (txt []string, err os.Error) { +func LookupTXT(name string) (txt []string, err error) { _, records, err := lookup(name, dnsTypeTXT) if err != nil { return @@ -153,7 +153,7 @@ func LookupTXT(name string) (txt []string, err os.Error) { // LookupAddr performs a reverse lookup for the given address, returning a list // of names mapping to that address. -func LookupAddr(addr string) (name []string, err os.Error) { +func LookupAddr(addr string) (name []string, err error) { name = lookupStaticAddr(addr) if len(name) > 0 { return diff --git a/libgo/go/net/lookup_windows.go b/libgo/go/net/lookup_windows.go index ea939f85986..53cb8f468ad 100644 --- a/libgo/go/net/lookup_windows.go +++ b/libgo/go/net/lookup_windows.go @@ -5,6 +5,7 @@ package net import ( + "errors" "syscall" "unsafe" "os" @@ -18,7 +19,7 @@ var ( ) // lookupProtocol looks up IP protocol name and returns correspondent protocol number. -func lookupProtocol(name string) (proto int, err os.Error) { +func lookupProtocol(name string) (proto int, err error) { protoentLock.Lock() defer protoentLock.Unlock() p, e := syscall.GetProtoByName(name) @@ -28,7 +29,7 @@ func lookupProtocol(name string) (proto int, err os.Error) { return int(p.Proto), nil } -func LookupHost(name string) (addrs []string, err os.Error) { +func LookupHost(name string) (addrs []string, err error) { ips, err := LookupIP(name) if err != nil { return @@ -40,7 +41,7 @@ func LookupHost(name string) (addrs []string, err os.Error) { return } -func LookupIP(name string) (addrs []IP, err os.Error) { +func LookupIP(name string) (addrs []IP, err error) { hostentLock.Lock() defer hostentLock.Unlock() h, e := syscall.GetHostByName(name) @@ -61,7 +62,7 @@ func LookupIP(name string) (addrs []IP, err os.Error) { return addrs, nil } -func LookupPort(network, service string) (port int, err os.Error) { +func LookupPort(network, service string) (port int, err error) { switch network { case "tcp4", "tcp6": network = "tcp" @@ -77,7 +78,7 @@ func LookupPort(network, service string) (port int, err os.Error) { return int(syscall.Ntohs(s.Port)), nil } -func LookupCNAME(name string) (cname string, err os.Error) { +func LookupCNAME(name string) (cname string, err error) { var r *syscall.DNSRecord e := syscall.DnsQuery(name, syscall.DNS_TYPE_CNAME, 0, nil, &r, nil) if int(e) != 0 { @@ -100,7 +101,7 @@ func LookupCNAME(name string) (cname string, err os.Error) { // That is, it looks up _service._proto.name. To accommodate services // publishing SRV records under non-standard names, if both service // and proto are empty strings, LookupSRV looks up name directly. -func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os.Error) { +func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) { var target string if service == "" && proto == "" { target = name @@ -122,7 +123,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err os. return name, addrs, nil } -func LookupMX(name string) (mx []*MX, err os.Error) { +func LookupMX(name string) (mx []*MX, err error) { var r *syscall.DNSRecord e := syscall.DnsQuery(name, syscall.DNS_TYPE_MX, 0, nil, &r, nil) if int(e) != 0 { @@ -138,11 +139,11 @@ func LookupMX(name string) (mx []*MX, err os.Error) { return mx, nil } -func LookupTXT(name string) (txt []string, err os.Error) { - return nil, os.NewError("net.LookupTXT is not implemented on Windows") +func LookupTXT(name string) (txt []string, err error) { + return nil, errors.New("net.LookupTXT is not implemented on Windows") } -func LookupAddr(addr string) (name []string, err os.Error) { +func LookupAddr(addr string) (name []string, err error) { arpa, err := reverseaddr(addr) if err != nil { return nil, err diff --git a/libgo/go/net/net.go b/libgo/go/net/net.go index 5c84d34348a..48f0ae791c8 100644 --- a/libgo/go/net/net.go +++ b/libgo/go/net/net.go @@ -9,7 +9,7 @@ package net // TODO(rsc): // support for raw ethernet sockets -import "os" +import "errors" // Addr represents a network end point address. type Addr interface { @@ -22,15 +22,15 @@ type Conn interface { // Read reads data from the connection. // Read can be made to time out and return a net.Error with Timeout() == true // after a fixed time limit; see SetTimeout and SetReadTimeout. - Read(b []byte) (n int, err os.Error) + Read(b []byte) (n int, err error) // Write writes data to the connection. // Write can be made to time out and return a net.Error with Timeout() == true // after a fixed time limit; see SetTimeout and SetWriteTimeout. - Write(b []byte) (n int, err os.Error) + Write(b []byte) (n int, err error) // Close closes the connection. - Close() os.Error + Close() error // LocalAddr returns the local network address. LocalAddr() Addr @@ -40,24 +40,24 @@ type Conn interface { // SetTimeout sets the read and write deadlines associated // with the connection. - SetTimeout(nsec int64) os.Error + SetTimeout(nsec int64) error // SetReadTimeout sets the time (in nanoseconds) that // Read will wait for data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. - SetReadTimeout(nsec int64) os.Error + SetReadTimeout(nsec int64) error // SetWriteTimeout sets the time (in nanoseconds) that // Write will wait to send its data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. - SetWriteTimeout(nsec int64) os.Error + SetWriteTimeout(nsec int64) error } // An Error represents a network error. type Error interface { - os.Error + error Timeout() bool // Is the error a timeout? Temporary() bool // Is the error temporary? } @@ -71,60 +71,60 @@ type PacketConn interface { // ReadFrom can be made to time out and return // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetReadTimeout. - ReadFrom(b []byte) (n int, addr Addr, err os.Error) + ReadFrom(b []byte) (n int, addr Addr, err error) // WriteTo writes a packet with payload b to addr. // WriteTo can be made to time out and return // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. - WriteTo(b []byte, addr Addr) (n int, err os.Error) + WriteTo(b []byte, addr Addr) (n int, err error) // Close closes the connection. - Close() os.Error + Close() error // LocalAddr returns the local network address. LocalAddr() Addr // SetTimeout sets the read and write deadlines associated // with the connection. - SetTimeout(nsec int64) os.Error + SetTimeout(nsec int64) error // SetReadTimeout sets the time (in nanoseconds) that // Read will wait for data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. - SetReadTimeout(nsec int64) os.Error + SetReadTimeout(nsec int64) error // SetWriteTimeout sets the time (in nanoseconds) that // Write will wait to send its data before returning an error with Timeout() == true. // Setting nsec == 0 (the default) disables the deadline. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. - SetWriteTimeout(nsec int64) os.Error + SetWriteTimeout(nsec int64) error } // A Listener is a generic network listener for stream-oriented protocols. type Listener interface { // Accept waits for and returns the next connection to the listener. - Accept() (c Conn, err os.Error) + Accept() (c Conn, err error) // Close closes the listener. - Close() os.Error + Close() error // Addr returns the listener's network address. Addr() Addr } -var errMissingAddress = os.NewError("missing address") +var errMissingAddress = errors.New("missing address") type OpError struct { - Op string - Net string - Addr Addr - Error os.Error + Op string + Net string + Addr Addr + Err error } -func (e *OpError) String() string { +func (e *OpError) Error() string { if e == nil { return "<nil>" } @@ -135,7 +135,7 @@ func (e *OpError) String() string { if e.Addr != nil { s += " " + e.Addr.String() } - s += ": " + e.Error.String() + s += ": " + e.Err.Error() return s } @@ -144,7 +144,7 @@ type temporary interface { } func (e *OpError) Temporary() bool { - t, ok := e.Error.(temporary) + t, ok := e.Err.(temporary) return ok && t.Temporary() } @@ -153,20 +153,20 @@ type timeout interface { } func (e *OpError) Timeout() bool { - t, ok := e.Error.(timeout) + t, ok := e.Err.(timeout) return ok && t.Timeout() } type AddrError struct { - Error string - Addr string + Err string + Addr string } -func (e *AddrError) String() string { +func (e *AddrError) Error() string { if e == nil { return "<nil>" } - s := e.Error + s := e.Err if e.Addr != "" { s += " " + e.Addr } @@ -183,6 +183,6 @@ func (e *AddrError) Timeout() bool { type UnknownNetworkError string -func (e UnknownNetworkError) String() string { return "unknown network " + string(e) } +func (e UnknownNetworkError) Error() string { return "unknown network " + string(e) } func (e UnknownNetworkError) Temporary() bool { return false } func (e UnknownNetworkError) Timeout() bool { return false } diff --git a/libgo/go/net/net_test.go b/libgo/go/net/net_test.go index 51cdac91bef..e1488ef38cc 100644 --- a/libgo/go/net/net_test.go +++ b/libgo/go/net/net_test.go @@ -6,7 +6,7 @@ package net import ( "flag" - "os" + "io" "regexp" "runtime" "testing" @@ -79,7 +79,7 @@ func TestDialError(t *testing.T) { t.Errorf("#%d: nil error, want match for %#q", i, tt.Pattern) continue } - s := e.String() + s := e.Error() match, _ := regexp.MatchString(tt.Pattern, s) if !match { t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern) @@ -119,8 +119,8 @@ func TestReverseAddress(t *testing.T) { if len(tt.ErrPrefix) == 0 && e != nil { t.Errorf("#%d: expected <nil>, got %q (error)", i, e) } - if e != nil && e.(*DNSError).Error != tt.ErrPrefix { - t.Errorf("#%d: expected %q, got %q (mismatched error)", i, tt.ErrPrefix, e.(*DNSError).Error) + if e != nil && e.(*DNSError).Err != tt.ErrPrefix { + t.Errorf("#%d: expected %q, got %q (mismatched error)", i, tt.ErrPrefix, e.(*DNSError).Err) } if a != tt.Reverse { t.Errorf("#%d: expected %q, got %q (reverse address)", i, tt.Reverse, a) @@ -146,7 +146,7 @@ func TestShutdown(t *testing.T) { } var buf [10]byte n, err := c.Read(buf[:]) - if n != 0 || err != os.EOF { + if n != 0 || err != io.EOF { t.Fatalf("server Read = %d, %v; want 0, os.EOF", n, err) } c.Write([]byte("response")) diff --git a/libgo/go/net/newpollserver.go b/libgo/go/net/newpollserver.go index 3c9a6da5373..9ad6f7ba276 100644 --- a/libgo/go/net/newpollserver.go +++ b/libgo/go/net/newpollserver.go @@ -11,7 +11,7 @@ import ( "syscall" ) -func newPollServer() (s *pollServer, err os.Error) { +func newPollServer() (s *pollServer, err error) { s = new(pollServer) s.cr = make(chan *netFD, 1) s.cw = make(chan *netFD, 1) diff --git a/libgo/go/net/parse.go b/libgo/go/net/parse.go index 0d30a7ac609..4c4200a49b7 100644 --- a/libgo/go/net/parse.go +++ b/libgo/go/net/parse.go @@ -54,7 +54,7 @@ func (f *file) readLine() (s string, ok bool) { if n >= 0 { f.data = f.data[0 : ln+n] } - if err == os.EOF { + if err == io.EOF { f.atEOF = true } } @@ -62,7 +62,7 @@ func (f *file) readLine() (s string, ok bool) { return } -func open(name string) (*file, os.Error) { +func open(name string) (*file, error) { fd, err := os.Open(name) if err != nil { return nil, err diff --git a/libgo/go/net/pipe.go b/libgo/go/net/pipe.go index c0bbd356b30..b99e6e658de 100644 --- a/libgo/go/net/pipe.go +++ b/libgo/go/net/pipe.go @@ -1,8 +1,8 @@ package net import ( + "errors" "io" - "os" ) // Pipe creates a synchronous, in-memory, full duplex @@ -32,7 +32,7 @@ func (pipeAddr) String() string { return "pipe" } -func (p *pipe) Close() os.Error { +func (p *pipe) Close() error { err := p.PipeReader.Close() err1 := p.PipeWriter.Close() if err == nil { @@ -49,14 +49,14 @@ func (p *pipe) RemoteAddr() Addr { return pipeAddr(0) } -func (p *pipe) SetTimeout(nsec int64) os.Error { - return os.NewError("net.Pipe does not support timeouts") +func (p *pipe) SetTimeout(nsec int64) error { + return errors.New("net.Pipe does not support timeouts") } -func (p *pipe) SetReadTimeout(nsec int64) os.Error { - return os.NewError("net.Pipe does not support timeouts") +func (p *pipe) SetReadTimeout(nsec int64) error { + return errors.New("net.Pipe does not support timeouts") } -func (p *pipe) SetWriteTimeout(nsec int64) os.Error { - return os.NewError("net.Pipe does not support timeouts") +func (p *pipe) SetWriteTimeout(nsec int64) error { + return errors.New("net.Pipe does not support timeouts") } diff --git a/libgo/go/net/pipe_test.go b/libgo/go/net/pipe_test.go index 7e4c6db4434..afe4f2408fa 100644 --- a/libgo/go/net/pipe_test.go +++ b/libgo/go/net/pipe_test.go @@ -7,7 +7,6 @@ package net import ( "bytes" "io" - "os" "testing" ) @@ -22,7 +21,7 @@ func checkWrite(t *testing.T, w io.Writer, data []byte, c chan int) { c <- 0 } -func checkRead(t *testing.T, r io.Reader, data []byte, wantErr os.Error) { +func checkRead(t *testing.T, r io.Reader, data []byte, wantErr error) { buf := make([]byte, len(data)+10) n, err := r.Read(buf) if err != wantErr { @@ -52,6 +51,6 @@ func TestPipe(t *testing.T) { checkRead(t, srv, []byte("a third line"), nil) <-c go srv.Close() - checkRead(t, cli, nil, os.EOF) + checkRead(t, cli, nil, io.EOF) cli.Close() } diff --git a/libgo/go/net/port.go b/libgo/go/net/port.go index a8ca60c60aa..80597f7555d 100644 --- a/libgo/go/net/port.go +++ b/libgo/go/net/port.go @@ -8,13 +8,10 @@ package net -import ( - "os" - "sync" -) +import "sync" var services map[string]map[string]int -var servicesError os.Error +var servicesError error var onceReadServices sync.Once func readServices() { @@ -53,7 +50,7 @@ func readServices() { } // goLookupPort is the native Go implementation of LookupPort. -func goLookupPort(network, service string) (port int, err os.Error) { +func goLookupPort(network, service string) (port int, err error) { onceReadServices.Do(readServices) switch network { diff --git a/libgo/go/net/sendfile_linux.go b/libgo/go/net/sendfile_linux.go index 6a5a06c8c54..36c75785789 100644 --- a/libgo/go/net/sendfile_linux.go +++ b/libgo/go/net/sendfile_linux.go @@ -21,7 +21,7 @@ const maxSendfileSize int = 4 << 20 // non-EOF error. // // if handled == false, sendFile performed no work. -func sendFile(c *netFD, r io.Reader) (written int64, err os.Error, handled bool) { +func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { var remain int64 = 1 << 62 // by default, copy until EOF lr, ok := r.(*io.LimitedReader) diff --git a/libgo/go/net/sendfile_stub.go b/libgo/go/net/sendfile_stub.go index c55be6c0801..b0adea47873 100644 --- a/libgo/go/net/sendfile_stub.go +++ b/libgo/go/net/sendfile_stub.go @@ -6,11 +6,8 @@ package net -import ( - "io" - "os" -) +import "io" -func sendFile(c *netFD, r io.Reader) (n int64, err os.Error, handled bool) { +func sendFile(c *netFD, r io.Reader) (n int64, err error, handled bool) { return 0, nil, false } diff --git a/libgo/go/net/sendfile_windows.go b/libgo/go/net/sendfile_windows.go index d9c2f537a3d..0b31572771c 100644 --- a/libgo/go/net/sendfile_windows.go +++ b/libgo/go/net/sendfile_windows.go @@ -33,7 +33,7 @@ func (o *sendfileOp) Name() string { // if handled == false, sendFile performed no work. // // Note that sendfile for windows does not suppport >2GB file. -func sendFile(c *netFD, r io.Reader) (written int64, err os.Error, handled bool) { +func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { var n int64 = 0 // by default, copy until EOF lr, ok := r.(*io.LimitedReader) diff --git a/libgo/go/net/server_test.go b/libgo/go/net/server_test.go index a2ff218e708..9e5444980f6 100644 --- a/libgo/go/net/server_test.go +++ b/libgo/go/net/server_test.go @@ -55,7 +55,7 @@ func runServe(t *testing.T, network, addr string, listening chan<- string, done func connect(t *testing.T, network, addr string, isEmpty bool) { var fd Conn - var err os.Error + var err error if network == "unixgram" { fd, err = DialUnix(network, &UnixAddr{addr + ".local", network}, &UnixAddr{addr, network}) } else { diff --git a/libgo/go/net/sock.go b/libgo/go/net/sock.go index 2359014ad63..d9df02cd63f 100644 --- a/libgo/go/net/sock.go +++ b/libgo/go/net/sock.go @@ -24,7 +24,7 @@ func boolint(b bool) int { } // Generic socket creation. -func socket(net string, f, p, t int, la, ra syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err os.Error) { +func socket(net string, f, p, t int, la, ra syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err error) { // See ../syscall/exec.go for description of ForkLock. syscall.ForkLock.RLock() s, e := syscall.Socket(f, p, t) @@ -67,74 +67,74 @@ func socket(net string, f, p, t int, la, ra syscall.Sockaddr, toAddr func(syscal return fd, nil } -func setsockoptInt(fd *netFD, level, opt int, value int) os.Error { +func setsockoptInt(fd *netFD, level, opt int, value int) error { return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, level, opt, value)) } -func setsockoptNsec(fd *netFD, level, opt int, nsec int64) os.Error { +func setsockoptNsec(fd *netFD, level, opt int, nsec int64) error { var tv = syscall.NsecToTimeval(nsec) return os.NewSyscallError("setsockopt", syscall.SetsockoptTimeval(fd.sysfd, level, opt, &tv)) } -func setReadBuffer(fd *netFD, bytes int) os.Error { +func setReadBuffer(fd *netFD, bytes int) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_RCVBUF, bytes) } -func setWriteBuffer(fd *netFD, bytes int) os.Error { +func setWriteBuffer(fd *netFD, bytes int) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_SNDBUF, bytes) } -func setReadTimeout(fd *netFD, nsec int64) os.Error { +func setReadTimeout(fd *netFD, nsec int64) error { fd.rdeadline_delta = nsec return nil } -func setWriteTimeout(fd *netFD, nsec int64) os.Error { +func setWriteTimeout(fd *netFD, nsec int64) error { fd.wdeadline_delta = nsec return nil } -func setTimeout(fd *netFD, nsec int64) os.Error { +func setTimeout(fd *netFD, nsec int64) error { if e := setReadTimeout(fd, nsec); e != nil { return e } return setWriteTimeout(fd, nsec) } -func setReuseAddr(fd *netFD, reuse bool) os.Error { +func setReuseAddr(fd *netFD, reuse bool) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, boolint(reuse)) } -func bindToDevice(fd *netFD, dev string) os.Error { +func bindToDevice(fd *netFD, dev string) error { // TODO(rsc): call setsockopt with null-terminated string pointer return os.EINVAL } -func setDontRoute(fd *netFD, dontroute bool) os.Error { +func setDontRoute(fd *netFD, dontroute bool) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_DONTROUTE, boolint(dontroute)) } -func setKeepAlive(fd *netFD, keepalive bool) os.Error { +func setKeepAlive(fd *netFD, keepalive bool) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, boolint(keepalive)) } -func setNoDelay(fd *netFD, noDelay bool) os.Error { +func setNoDelay(fd *netFD, noDelay bool) error { fd.incref() defer fd.decref() return setsockoptInt(fd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, boolint(noDelay)) } -func setLinger(fd *netFD, sec int) os.Error { +func setLinger(fd *netFD, sec int) error { var l syscall.Linger if sec >= 0 { l.Onoff = 1 @@ -153,7 +153,7 @@ type UnknownSocketError struct { sa syscall.Sockaddr } -func (e *UnknownSocketError) String() string { +func (e *UnknownSocketError) Error() string { return "unknown socket address type " + reflect.TypeOf(e.sa).String() } @@ -163,7 +163,7 @@ type writerOnly struct { // Fallback implementation of io.ReaderFrom's ReadFrom, when sendfile isn't // applicable. -func genericReadFrom(w io.Writer, r io.Reader) (n int64, err os.Error) { +func genericReadFrom(w io.Writer, r io.Reader) (n int64, err error) { // Use wrapper to hide existing r.ReadFrom from io.Copy. return io.Copy(writerOnly{w}, r) } diff --git a/libgo/go/net/tcpsock.go b/libgo/go/net/tcpsock.go index f5c0a278107..47fbf29198c 100644 --- a/libgo/go/net/tcpsock.go +++ b/libgo/go/net/tcpsock.go @@ -6,10 +6,6 @@ package net -import ( - "os" -) - // TCPAddr represents the address of a TCP end point. type TCPAddr struct { IP IP @@ -31,7 +27,7 @@ func (a *TCPAddr) String() string { // numeric addresses on the network net, which must be "tcp", // "tcp4" or "tcp6". A literal IPv6 host address must be // enclosed in square brackets, as in "[::]:80". -func ResolveTCPAddr(net, addr string) (*TCPAddr, os.Error) { +func ResolveTCPAddr(net, addr string) (*TCPAddr, error) { ip, port, err := hostPortToIP(net, addr) if err != nil { return nil, err diff --git a/libgo/go/net/tcpsock_plan9.go b/libgo/go/net/tcpsock_plan9.go index 3319e57c338..69fae036144 100644 --- a/libgo/go/net/tcpsock_plan9.go +++ b/libgo/go/net/tcpsock_plan9.go @@ -18,7 +18,7 @@ type TCPConn struct { // CloseRead shuts down the reading side of the TCP connection. // Most callers should just use Close. -func (c *TCPConn) CloseRead() os.Error { +func (c *TCPConn) CloseRead() error { if !c.ok() { return os.EINVAL } @@ -27,7 +27,7 @@ func (c *TCPConn) CloseRead() os.Error { // CloseWrite shuts down the writing side of the TCP connection. // Most callers should just use Close. -func (c *TCPConn) CloseWrite() os.Error { +func (c *TCPConn) CloseWrite() error { if !c.ok() { return os.EINVAL } @@ -37,7 +37,7 @@ func (c *TCPConn) CloseWrite() os.Error { // DialTCP connects to the remote address raddr on the network net, // which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used // as the local address for the connection. -func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err os.Error) { +func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) { switch net { case "tcp", "tcp4", "tcp6": default: @@ -64,7 +64,7 @@ type TCPListener struct { // Net must be "tcp", "tcp4", or "tcp6". // If laddr has a port of 0, it means to listen on some available port. // The caller can use l.Addr() to retrieve the chosen address. -func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err os.Error) { +func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err error) { switch net { case "tcp", "tcp4", "tcp6": default: diff --git a/libgo/go/net/tcpsock_posix.go b/libgo/go/net/tcpsock_posix.go index 740a63d3038..a726b45c15a 100644 --- a/libgo/go/net/tcpsock_posix.go +++ b/libgo/go/net/tcpsock_posix.go @@ -39,7 +39,7 @@ func (a *TCPAddr) family() int { return syscall.AF_INET6 } -func (a *TCPAddr) sockaddr(family int) (syscall.Sockaddr, os.Error) { +func (a *TCPAddr) sockaddr(family int) (syscall.Sockaddr, error) { return ipToSockaddr(family, a.IP, a.Port) } @@ -67,7 +67,7 @@ func (c *TCPConn) ok() bool { return c != nil && c.fd != nil } // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *TCPConn) Read(b []byte) (n int, err os.Error) { +func (c *TCPConn) Read(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -75,7 +75,7 @@ func (c *TCPConn) Read(b []byte) (n int, err os.Error) { } // ReadFrom implements the io.ReaderFrom ReadFrom method. -func (c *TCPConn) ReadFrom(r io.Reader) (int64, os.Error) { +func (c *TCPConn) ReadFrom(r io.Reader) (int64, error) { if n, err, handled := sendFile(c.fd, r); handled { return n, err } @@ -83,7 +83,7 @@ func (c *TCPConn) ReadFrom(r io.Reader) (int64, os.Error) { } // Write implements the net.Conn Write method. -func (c *TCPConn) Write(b []byte) (n int, err os.Error) { +func (c *TCPConn) Write(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -91,7 +91,7 @@ func (c *TCPConn) Write(b []byte) (n int, err os.Error) { } // Close closes the TCP connection. -func (c *TCPConn) Close() os.Error { +func (c *TCPConn) Close() error { if !c.ok() { return os.EINVAL } @@ -102,7 +102,7 @@ func (c *TCPConn) Close() os.Error { // CloseRead shuts down the reading side of the TCP connection. // Most callers should just use Close. -func (c *TCPConn) CloseRead() os.Error { +func (c *TCPConn) CloseRead() error { if !c.ok() { return os.EINVAL } @@ -111,7 +111,7 @@ func (c *TCPConn) CloseRead() os.Error { // CloseWrite shuts down the writing side of the TCP connection. // Most callers should just use Close. -func (c *TCPConn) CloseWrite() os.Error { +func (c *TCPConn) CloseWrite() error { if !c.ok() { return os.EINVAL } @@ -135,7 +135,7 @@ func (c *TCPConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *TCPConn) SetTimeout(nsec int64) os.Error { +func (c *TCPConn) SetTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -143,7 +143,7 @@ func (c *TCPConn) SetTimeout(nsec int64) os.Error { } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *TCPConn) SetReadTimeout(nsec int64) os.Error { +func (c *TCPConn) SetReadTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -151,7 +151,7 @@ func (c *TCPConn) SetReadTimeout(nsec int64) os.Error { } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *TCPConn) SetWriteTimeout(nsec int64) os.Error { +func (c *TCPConn) SetWriteTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -160,7 +160,7 @@ func (c *TCPConn) SetWriteTimeout(nsec int64) os.Error { // SetReadBuffer sets the size of the operating system's // receive buffer associated with the connection. -func (c *TCPConn) SetReadBuffer(bytes int) os.Error { +func (c *TCPConn) SetReadBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -169,7 +169,7 @@ func (c *TCPConn) SetReadBuffer(bytes int) os.Error { // SetWriteBuffer sets the size of the operating system's // transmit buffer associated with the connection. -func (c *TCPConn) SetWriteBuffer(bytes int) os.Error { +func (c *TCPConn) SetWriteBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -187,7 +187,7 @@ func (c *TCPConn) SetWriteBuffer(bytes int) os.Error { // // If sec > 0, Close blocks for at most sec seconds waiting for // data to be sent and acknowledged. -func (c *TCPConn) SetLinger(sec int) os.Error { +func (c *TCPConn) SetLinger(sec int) error { if !c.ok() { return os.EINVAL } @@ -196,7 +196,7 @@ func (c *TCPConn) SetLinger(sec int) os.Error { // SetKeepAlive sets whether the operating system should send // keepalive messages on the connection. -func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error { +func (c *TCPConn) SetKeepAlive(keepalive bool) error { if !c.ok() { return os.EINVAL } @@ -207,7 +207,7 @@ func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error { // packet transmission in hopes of sending fewer packets // (Nagle's algorithm). The default is true (no delay), meaning // that data is sent as soon as possible after a Write. -func (c *TCPConn) SetNoDelay(noDelay bool) os.Error { +func (c *TCPConn) SetNoDelay(noDelay bool) error { if !c.ok() { return os.EINVAL } @@ -217,12 +217,12 @@ func (c *TCPConn) SetNoDelay(noDelay bool) os.Error { // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (c *TCPConn) File() (f *os.File, err os.Error) { return c.fd.dup() } +func (c *TCPConn) File() (f *os.File, err error) { return c.fd.dup() } // DialTCP connects to the remote address raddr on the network net, // which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used // as the local address for the connection. -func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err os.Error) { +func DialTCP(net string, laddr, raddr *TCPAddr) (c *TCPConn, err error) { if raddr == nil { return nil, &OpError{"dial", "tcp", nil, errMissingAddress} } @@ -244,7 +244,7 @@ type TCPListener struct { // Net must be "tcp", "tcp4", or "tcp6". // If laddr has a port of 0, it means to listen on some available port. // The caller can use l.Addr() to retrieve the chosen address. -func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err os.Error) { +func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err error) { fd, err := internetSocket(net, laddr.toAddr(), nil, syscall.SOCK_STREAM, 0, "listen", sockaddrToTCP) if err != nil { return nil, err @@ -261,7 +261,7 @@ func ListenTCP(net string, laddr *TCPAddr) (l *TCPListener, err os.Error) { // AcceptTCP accepts the next incoming call and returns the new connection // and the remote address. -func (l *TCPListener) AcceptTCP() (c *TCPConn, err os.Error) { +func (l *TCPListener) AcceptTCP() (c *TCPConn, err error) { if l == nil || l.fd == nil || l.fd.sysfd < 0 { return nil, os.EINVAL } @@ -274,7 +274,7 @@ func (l *TCPListener) AcceptTCP() (c *TCPConn, err os.Error) { // Accept implements the Accept method in the Listener interface; // it waits for the next call and returns a generic Conn. -func (l *TCPListener) Accept() (c Conn, err os.Error) { +func (l *TCPListener) Accept() (c Conn, err error) { c1, err := l.AcceptTCP() if err != nil { return nil, err @@ -284,7 +284,7 @@ func (l *TCPListener) Accept() (c Conn, err os.Error) { // Close stops listening on the TCP address. // Already Accepted connections are not closed. -func (l *TCPListener) Close() os.Error { +func (l *TCPListener) Close() error { if l == nil || l.fd == nil { return os.EINVAL } @@ -295,7 +295,7 @@ func (l *TCPListener) Close() os.Error { func (l *TCPListener) Addr() Addr { return l.fd.laddr } // SetTimeout sets the deadline associated with the listener -func (l *TCPListener) SetTimeout(nsec int64) os.Error { +func (l *TCPListener) SetTimeout(nsec int64) error { if l == nil || l.fd == nil { return os.EINVAL } @@ -305,4 +305,4 @@ func (l *TCPListener) SetTimeout(nsec int64) os.Error { // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (l *TCPListener) File() (f *os.File, err os.Error) { return l.fd.dup() } +func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } diff --git a/libgo/go/net/textproto/reader.go b/libgo/go/net/textproto/reader.go index 98b39276b8a..658b5c282ec 100644 --- a/libgo/go/net/textproto/reader.go +++ b/libgo/go/net/textproto/reader.go @@ -9,7 +9,6 @@ import ( "bytes" "io" "io/ioutil" - "os" "strconv" "strings" ) @@ -32,13 +31,13 @@ func NewReader(r *bufio.Reader) *Reader { // ReadLine reads a single line from r, // eliding the final \n or \r\n from the returned string. -func (r *Reader) ReadLine() (string, os.Error) { +func (r *Reader) ReadLine() (string, error) { line, err := r.readLineSlice() return string(line), err } // ReadLineBytes is like ReadLine but returns a []byte instead of a string. -func (r *Reader) ReadLineBytes() ([]byte, os.Error) { +func (r *Reader) ReadLineBytes() ([]byte, error) { line, err := r.readLineSlice() if line != nil { buf := make([]byte, len(line)) @@ -48,7 +47,7 @@ func (r *Reader) ReadLineBytes() ([]byte, os.Error) { return line, err } -func (r *Reader) readLineSlice() ([]byte, os.Error) { +func (r *Reader) readLineSlice() ([]byte, error) { r.closeDot() var line []byte for { @@ -87,7 +86,7 @@ func (r *Reader) readLineSlice() ([]byte, os.Error) { // // A line consisting of only white space is never continued. // -func (r *Reader) ReadContinuedLine() (string, os.Error) { +func (r *Reader) ReadContinuedLine() (string, error) { line, err := r.readContinuedLineSlice() return string(line), err } @@ -108,7 +107,7 @@ func trim(s []byte) []byte { // ReadContinuedLineBytes is like ReadContinuedLine but // returns a []byte instead of a string. -func (r *Reader) ReadContinuedLineBytes() ([]byte, os.Error) { +func (r *Reader) ReadContinuedLineBytes() ([]byte, error) { line, err := r.readContinuedLineSlice() if line != nil { buf := make([]byte, len(line)) @@ -118,7 +117,7 @@ func (r *Reader) ReadContinuedLineBytes() ([]byte, os.Error) { return line, err } -func (r *Reader) readContinuedLineSlice() ([]byte, os.Error) { +func (r *Reader) readContinuedLineSlice() ([]byte, error) { // Read the first line. line, err := r.readLineSlice() if err != nil { @@ -192,7 +191,7 @@ func (r *Reader) readContinuedLineSlice() ([]byte, os.Error) { return line, err } -func (r *Reader) readCodeLine(expectCode int) (code int, continued bool, message string, err os.Error) { +func (r *Reader) readCodeLine(expectCode int) (code int, continued bool, message string, err error) { line, err := r.ReadLine() if err != nil { return @@ -200,7 +199,7 @@ func (r *Reader) readCodeLine(expectCode int) (code int, continued bool, message return parseCodeLine(line, expectCode) } -func parseCodeLine(line string, expectCode int) (code int, continued bool, message string, err os.Error) { +func parseCodeLine(line string, expectCode int) (code int, continued bool, message string, err error) { if len(line) < 4 || line[3] != ' ' && line[3] != '-' { err = ProtocolError("short response: " + line) return @@ -235,7 +234,7 @@ func parseCodeLine(line string, expectCode int) (code int, continued bool, messa // // An expectCode <= 0 disables the check of the status code. // -func (r *Reader) ReadCodeLine(expectCode int) (code int, message string, err os.Error) { +func (r *Reader) ReadCodeLine(expectCode int) (code int, message string, err error) { code, continued, message, err := r.readCodeLine(expectCode) if err == nil && continued { err = ProtocolError("unexpected multi-line response: " + message) @@ -265,7 +264,7 @@ func (r *Reader) ReadCodeLine(expectCode int) (code int, message string, err os. // // An expectCode <= 0 disables the check of the status code. // -func (r *Reader) ReadResponse(expectCode int) (code int, message string, err os.Error) { +func (r *Reader) ReadResponse(expectCode int) (code int, message string, err error) { code, continued, message, err := r.readCodeLine(expectCode) for err == nil && continued { line, err := r.ReadLine() @@ -314,7 +313,7 @@ type dotReader struct { } // Read satisfies reads by decoding dot-encoded data read from d.r. -func (d *dotReader) Read(b []byte) (n int, err os.Error) { +func (d *dotReader) Read(b []byte) (n int, err error) { // Run data through a simple state machine to // elide leading dots, rewrite trailing \r\n into \n, // and detect ending .\r\n line. @@ -331,7 +330,7 @@ func (d *dotReader) Read(b []byte) (n int, err os.Error) { var c byte c, err = br.ReadByte() if err != nil { - if err == os.EOF { + if err == io.EOF { err = io.ErrUnexpectedEOF } break @@ -393,7 +392,7 @@ func (d *dotReader) Read(b []byte) (n int, err os.Error) { n++ } if err == nil && d.state == stateEOF { - err = os.EOF + err = io.EOF } if err != nil && d.r.dot == d { d.r.dot = nil @@ -418,7 +417,7 @@ func (r *Reader) closeDot() { // ReadDotBytes reads a dot-encoding and returns the decoded data. // // See the documentation for the DotReader method for details about dot-encoding. -func (r *Reader) ReadDotBytes() ([]byte, os.Error) { +func (r *Reader) ReadDotBytes() ([]byte, error) { return ioutil.ReadAll(r.DotReader()) } @@ -426,17 +425,17 @@ func (r *Reader) ReadDotBytes() ([]byte, os.Error) { // containing the decoded lines, with the final \r\n or \n elided from each. // // See the documentation for the DotReader method for details about dot-encoding. -func (r *Reader) ReadDotLines() ([]string, os.Error) { +func (r *Reader) ReadDotLines() ([]string, error) { // We could use ReadDotBytes and then Split it, // but reading a line at a time avoids needing a // large contiguous block of memory and is simpler. var v []string - var err os.Error + var err error for { var line string line, err = r.ReadLine() if err != nil { - if err == os.EOF { + if err == io.EOF { err = io.ErrUnexpectedEOF } break @@ -474,7 +473,7 @@ func (r *Reader) ReadDotLines() ([]string, os.Error) { // "Long-Key": {"Even Longer Value"}, // } // -func (r *Reader) ReadMIMEHeader() (MIMEHeader, os.Error) { +func (r *Reader) ReadMIMEHeader() (MIMEHeader, error) { m := make(MIMEHeader) for { kv, err := r.readContinuedLineSlice() diff --git a/libgo/go/net/textproto/reader_test.go b/libgo/go/net/textproto/reader_test.go index a087e29d914..5aefe39867d 100644 --- a/libgo/go/net/textproto/reader_test.go +++ b/libgo/go/net/textproto/reader_test.go @@ -7,7 +7,6 @@ package textproto import ( "bufio" "io" - "os" "reflect" "strings" "testing" @@ -49,7 +48,7 @@ func TestReadLine(t *testing.T) { t.Fatalf("Line 2: %s, %v", s, err) } s, err = r.ReadLine() - if s != "" || err != os.EOF { + if s != "" || err != io.EOF { t.Fatalf("EOF: %s, %v", s, err) } } @@ -69,7 +68,7 @@ func TestReadContinuedLine(t *testing.T) { t.Fatalf("Line 3: %s, %v", s, err) } s, err = r.ReadContinuedLine() - if s != "" || err != os.EOF { + if s != "" || err != io.EOF { t.Fatalf("EOF: %s, %v", s, err) } } @@ -92,7 +91,7 @@ func TestReadCodeLine(t *testing.T) { t.Fatalf("Line 3: wrong error %v\n", err) } code, msg, err = r.ReadCodeLine(1) - if code != 0 || msg != "" || err != os.EOF { + if code != 0 || msg != "" || err != io.EOF { t.Fatalf("EOF: %d, %s, %v", code, msg, err) } } diff --git a/libgo/go/net/textproto/textproto.go b/libgo/go/net/textproto/textproto.go index 9f19b5495d1..317ec72b0cc 100644 --- a/libgo/go/net/textproto/textproto.go +++ b/libgo/go/net/textproto/textproto.go @@ -27,7 +27,6 @@ import ( "fmt" "io" "net" - "os" ) // An Error represents a numeric error response from a server. @@ -36,7 +35,7 @@ type Error struct { Msg string } -func (e *Error) String() string { +func (e *Error) Error() string { return fmt.Sprintf("%03d %s", e.Code, e.Msg) } @@ -44,7 +43,7 @@ func (e *Error) String() string { // as an invalid response or a hung-up connection. type ProtocolError string -func (p ProtocolError) String() string { +func (p ProtocolError) Error() string { return string(p) } @@ -70,13 +69,13 @@ func NewConn(conn io.ReadWriteCloser) *Conn { } // Close closes the connection. -func (c *Conn) Close() os.Error { +func (c *Conn) Close() error { return c.conn.Close() } // Dial connects to the given address on the given network using net.Dial // and then returns a new Conn for the connection. -func Dial(network, addr string) (*Conn, os.Error) { +func Dial(network, addr string) (*Conn, error) { c, err := net.Dial(network, addr) if err != nil { return nil, err @@ -109,7 +108,7 @@ func Dial(network, addr string) (*Conn, os.Error) { // } // return c.ReadCodeLine(250) // -func (c *Conn) Cmd(format string, args ...interface{}) (id uint, err os.Error) { +func (c *Conn) Cmd(format string, args ...interface{}) (id uint, err error) { id = c.Next() c.StartRequest(id) err = c.PrintfLine(format, args...) diff --git a/libgo/go/net/textproto/writer.go b/libgo/go/net/textproto/writer.go index 4e705f6c3ea..03e2fd658e4 100644 --- a/libgo/go/net/textproto/writer.go +++ b/libgo/go/net/textproto/writer.go @@ -8,7 +8,6 @@ import ( "bufio" "fmt" "io" - "os" ) // A Writer implements convenience methods for writing @@ -27,7 +26,7 @@ var crnl = []byte{'\r', '\n'} var dotcrnl = []byte{'.', '\r', '\n'} // PrintfLine writes the formatted output followed by \r\n. -func (w *Writer) PrintfLine(format string, args ...interface{}) os.Error { +func (w *Writer) PrintfLine(format string, args ...interface{}) error { w.closeDot() fmt.Fprintf(w.W, format, args...) w.W.Write(crnl) @@ -64,7 +63,7 @@ const ( wstateData // writing data in middle of line ) -func (d *dotWriter) Write(b []byte) (n int, err os.Error) { +func (d *dotWriter) Write(b []byte) (n int, err error) { bw := d.w.W for n < len(b) { c := b[n] @@ -100,7 +99,7 @@ func (d *dotWriter) Write(b []byte) (n int, err os.Error) { return } -func (d *dotWriter) Close() os.Error { +func (d *dotWriter) Close() error { if d.w.dot == d { d.w.dot = nil } diff --git a/libgo/go/net/timeout_test.go b/libgo/go/net/timeout_test.go index 2c2c36fff5e..3c884ca7cfe 100644 --- a/libgo/go/net/timeout_test.go +++ b/libgo/go/net/timeout_test.go @@ -5,7 +5,6 @@ package net import ( - "os" "runtime" "testing" "time" @@ -22,7 +21,7 @@ func testTimeout(t *testing.T, network, addr string, readFrom bool) { fd.SetReadTimeout(1e8) // 100ms var b [100]byte var n int - var err1 os.Error + var err1 error if readFrom { n, _, err1 = fd.(PacketConn).ReadFrom(b[0:]) } else { diff --git a/libgo/go/net/udpsock.go b/libgo/go/net/udpsock.go index 3dfa71675f9..b3520cf09f3 100644 --- a/libgo/go/net/udpsock.go +++ b/libgo/go/net/udpsock.go @@ -6,10 +6,6 @@ package net -import ( - "os" -) - // UDPAddr represents the address of a UDP end point. type UDPAddr struct { IP IP @@ -31,7 +27,7 @@ func (a *UDPAddr) String() string { // numeric addresses on the network net, which must be "udp", // "udp4" or "udp6". A literal IPv6 host address must be // enclosed in square brackets, as in "[::]:80". -func ResolveUDPAddr(net, addr string) (*UDPAddr, os.Error) { +func ResolveUDPAddr(net, addr string) (*UDPAddr, error) { ip, port, err := hostPortToIP(net, addr) if err != nil { return nil, err diff --git a/libgo/go/net/udpsock_plan9.go b/libgo/go/net/udpsock_plan9.go index d5c6ccb9046..60dec812289 100644 --- a/libgo/go/net/udpsock_plan9.go +++ b/libgo/go/net/udpsock_plan9.go @@ -7,6 +7,7 @@ package net import ( + "errors" "os" ) @@ -24,7 +25,7 @@ type UDPConn struct { // // ReadFromUDP can be made to time out and return an error with Timeout() == true // after a fixed time limit; see SetTimeout and SetReadTimeout. -func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) { +func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -40,7 +41,7 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) { return } if m < udpHeaderSize { - return 0, nil, os.NewError("short read reading UDP header") + return 0, nil, errors.New("short read reading UDP header") } buf = buf[:m] @@ -50,7 +51,7 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) { } // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -63,7 +64,7 @@ func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. -func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error) { +func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -87,7 +88,7 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error) { } // WriteTo implements the net.PacketConn WriteTo method. -func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -101,7 +102,7 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { // DialUDP connects to the remote address raddr on the network net, // which must be "udp", "udp4", or "udp6". If laddr is not nil, it is used // as the local address for the connection. -func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err os.Error) { +func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) { switch net { case "udp", "udp4", "udp6": default: @@ -149,7 +150,7 @@ func unmarshalUDPHeader(b []byte) (*udpHeader, []byte) { // local address laddr. The returned connection c's ReadFrom // and WriteTo methods can be used to receive and send UDP // packets with per-packet addressing. -func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) { +func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) { switch net { case "udp", "udp4", "udp6": default: @@ -172,7 +173,7 @@ func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) { // JoinGroup joins the IP multicast group named by addr on ifi, // which specifies the interface to join. JoinGroup uses the // default multicast interface if ifi is nil. -func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) os.Error { +func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) error { if !c.ok() { return os.EINVAL } @@ -180,7 +181,7 @@ func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) os.Error { } // LeaveGroup exits the IP multicast group named by addr on ifi. -func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) os.Error { +func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) error { if !c.ok() { return os.EINVAL } diff --git a/libgo/go/net/udpsock_posix.go b/libgo/go/net/udpsock_posix.go index 06298ee40c8..2cfcc609d43 100644 --- a/libgo/go/net/udpsock_posix.go +++ b/libgo/go/net/udpsock_posix.go @@ -34,7 +34,7 @@ func (a *UDPAddr) family() int { return syscall.AF_INET6 } -func (a *UDPAddr) sockaddr(family int) (syscall.Sockaddr, os.Error) { +func (a *UDPAddr) sockaddr(family int) (syscall.Sockaddr, error) { return ipToSockaddr(family, a.IP, a.Port) } @@ -58,7 +58,7 @@ func (c *UDPConn) ok() bool { return c != nil && c.fd != nil } // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *UDPConn) Read(b []byte) (n int, err os.Error) { +func (c *UDPConn) Read(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -66,7 +66,7 @@ func (c *UDPConn) Read(b []byte) (n int, err os.Error) { } // Write implements the net.Conn Write method. -func (c *UDPConn) Write(b []byte) (n int, err os.Error) { +func (c *UDPConn) Write(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -74,7 +74,7 @@ func (c *UDPConn) Write(b []byte) (n int, err os.Error) { } // Close closes the UDP connection. -func (c *UDPConn) Close() os.Error { +func (c *UDPConn) Close() error { if !c.ok() { return os.EINVAL } @@ -100,7 +100,7 @@ func (c *UDPConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *UDPConn) SetTimeout(nsec int64) os.Error { +func (c *UDPConn) SetTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -108,7 +108,7 @@ func (c *UDPConn) SetTimeout(nsec int64) os.Error { } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *UDPConn) SetReadTimeout(nsec int64) os.Error { +func (c *UDPConn) SetReadTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -116,7 +116,7 @@ func (c *UDPConn) SetReadTimeout(nsec int64) os.Error { } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *UDPConn) SetWriteTimeout(nsec int64) os.Error { +func (c *UDPConn) SetWriteTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -125,7 +125,7 @@ func (c *UDPConn) SetWriteTimeout(nsec int64) os.Error { // SetReadBuffer sets the size of the operating system's // receive buffer associated with the connection. -func (c *UDPConn) SetReadBuffer(bytes int) os.Error { +func (c *UDPConn) SetReadBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -134,7 +134,7 @@ func (c *UDPConn) SetReadBuffer(bytes int) os.Error { // SetWriteBuffer sets the size of the operating system's // transmit buffer associated with the connection. -func (c *UDPConn) SetWriteBuffer(bytes int) os.Error { +func (c *UDPConn) SetWriteBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -149,7 +149,7 @@ func (c *UDPConn) SetWriteBuffer(bytes int) os.Error { // // ReadFromUDP can be made to time out and return an error with Timeout() == true // after a fixed time limit; see SetTimeout and SetReadTimeout. -func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) { +func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -164,7 +164,7 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) { } // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -178,19 +178,19 @@ func (c *UDPConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. -func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err os.Error) { +func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } sa, err1 := addr.sockaddr(c.fd.family) if err1 != nil { - return 0, &OpError{Op: "write", Net: "udp", Addr: addr, Error: err1} + return 0, &OpError{Op: "write", Net: "udp", Addr: addr, Err: err1} } return c.fd.WriteTo(b, sa) } // WriteTo implements the net.PacketConn WriteTo method. -func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -204,7 +204,7 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { // DialUDP connects to the remote address raddr on the network net, // which must be "udp", "udp4", or "udp6". If laddr is not nil, it is used // as the local address for the connection. -func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err os.Error) { +func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err error) { switch net { case "udp", "udp4", "udp6": default: @@ -224,7 +224,7 @@ func DialUDP(net string, laddr, raddr *UDPAddr) (c *UDPConn, err os.Error) { // local address laddr. The returned connection c's ReadFrom // and WriteTo methods can be used to receive and send UDP // packets with per-packet addressing. -func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) { +func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) { switch net { case "udp", "udp4", "udp6": default: @@ -241,7 +241,7 @@ func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err os.Error) { } // BindToDevice binds a UDPConn to a network interface. -func (c *UDPConn) BindToDevice(device string) os.Error { +func (c *UDPConn) BindToDevice(device string) error { if !c.ok() { return os.EINVAL } @@ -253,12 +253,12 @@ func (c *UDPConn) BindToDevice(device string) os.Error { // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (c *UDPConn) File() (f *os.File, err os.Error) { return c.fd.dup() } +func (c *UDPConn) File() (f *os.File, err error) { return c.fd.dup() } // JoinGroup joins the IP multicast group named by addr on ifi, // which specifies the interface to join. JoinGroup uses the // default multicast interface if ifi is nil. -func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) os.Error { +func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) error { if !c.ok() { return os.EINVAL } @@ -270,7 +270,7 @@ func (c *UDPConn) JoinGroup(ifi *Interface, addr IP) os.Error { } // LeaveGroup exits the IP multicast group named by addr on ifi. -func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) os.Error { +func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) error { if !c.ok() { return os.EINVAL } @@ -281,7 +281,7 @@ func (c *UDPConn) LeaveGroup(ifi *Interface, addr IP) os.Error { return leaveIPv6GroupUDP(c, ifi, addr) } -func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { +func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { mreq := &syscall.IPMreq{Multiaddr: [4]byte{ip[0], ip[1], ip[2], ip[3]}} if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil { return &OpError{"joinipv4group", "udp", &IPAddr{ip}, err} @@ -292,7 +292,7 @@ func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { return nil } -func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { +func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { mreq := &syscall.IPMreq{Multiaddr: [4]byte{ip[0], ip[1], ip[2], ip[3]}} if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil { return &OpError{"leaveipv4group", "udp", &IPAddr{ip}, err} @@ -303,7 +303,7 @@ func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { return nil } -func setIPv4InterfaceToJoin(mreq *syscall.IPMreq, ifi *Interface) os.Error { +func setIPv4InterfaceToJoin(mreq *syscall.IPMreq, ifi *Interface) error { if ifi == nil { return nil } @@ -323,7 +323,7 @@ func setIPv4InterfaceToJoin(mreq *syscall.IPMreq, ifi *Interface) os.Error { return nil } -func joinIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { +func joinIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], ip) if ifi != nil { @@ -335,7 +335,7 @@ func joinIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { return nil } -func leaveIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) os.Error { +func leaveIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], ip) if ifi != nil { diff --git a/libgo/go/net/unixsock.go b/libgo/go/net/unixsock.go index d5040f9a297..ae0956958f3 100644 --- a/libgo/go/net/unixsock.go +++ b/libgo/go/net/unixsock.go @@ -6,10 +6,6 @@ package net -import ( - "os" -) - // UnixAddr represents the address of a Unix domain socket end point. type UnixAddr struct { Name string @@ -38,7 +34,7 @@ func (a *UnixAddr) toAddr() Addr { // ResolveUnixAddr parses addr as a Unix domain socket address. // The string net gives the network name, "unix", "unixgram" or // "unixpacket". -func ResolveUnixAddr(net, addr string) (*UnixAddr, os.Error) { +func ResolveUnixAddr(net, addr string) (*UnixAddr, error) { switch net { case "unix": case "unixpacket": diff --git a/libgo/go/net/unixsock_plan9.go b/libgo/go/net/unixsock_plan9.go index 7e212df8a3b..ac502d1d76a 100644 --- a/libgo/go/net/unixsock_plan9.go +++ b/libgo/go/net/unixsock_plan9.go @@ -17,17 +17,17 @@ type UnixConn bool // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *UnixConn) Read(b []byte) (n int, err os.Error) { +func (c *UnixConn) Read(b []byte) (n int, err error) { return 0, os.EPLAN9 } // Write implements the net.Conn Write method. -func (c *UnixConn) Write(b []byte) (n int, err os.Error) { +func (c *UnixConn) Write(b []byte) (n int, err error) { return 0, os.EPLAN9 } // Close closes the Unix domain connection. -func (c *UnixConn) Close() os.Error { +func (c *UnixConn) Close() error { return os.EPLAN9 } @@ -45,28 +45,28 @@ func (c *UnixConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *UnixConn) SetTimeout(nsec int64) os.Error { +func (c *UnixConn) SetTimeout(nsec int64) error { return os.EPLAN9 } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *UnixConn) SetReadTimeout(nsec int64) os.Error { +func (c *UnixConn) SetReadTimeout(nsec int64) error { return os.EPLAN9 } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *UnixConn) SetWriteTimeout(nsec int64) os.Error { +func (c *UnixConn) SetWriteTimeout(nsec int64) error { return os.EPLAN9 } // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err error) { err = os.EPLAN9 return } // WriteTo implements the net.PacketConn WriteTo method. -func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err error) { err = os.EPLAN9 return } @@ -74,7 +74,7 @@ func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { // DialUnix connects to the remote address raddr on the network net, // which must be "unix" or "unixgram". If laddr is not nil, it is used // as the local address for the connection. -func DialUnix(net string, laddr, raddr *UnixAddr) (c *UnixConn, err os.Error) { +func DialUnix(net string, laddr, raddr *UnixAddr) (c *UnixConn, err error) { return nil, os.EPLAN9 } @@ -85,19 +85,19 @@ type UnixListener bool // ListenUnix announces on the Unix domain socket laddr and returns a Unix listener. // Net must be "unix" (stream sockets). -func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error) { +func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err error) { return nil, os.EPLAN9 } // Accept implements the Accept method in the Listener interface; // it waits for the next call and returns a generic Conn. -func (l *UnixListener) Accept() (c Conn, err os.Error) { +func (l *UnixListener) Accept() (c Conn, err error) { return nil, os.EPLAN9 } // Close stops listening on the Unix address. // Already accepted connections are not closed. -func (l *UnixListener) Close() os.Error { +func (l *UnixListener) Close() error { return os.EPLAN9 } diff --git a/libgo/go/net/unixsock_posix.go b/libgo/go/net/unixsock_posix.go index fccf0189c05..6ba692e5083 100644 --- a/libgo/go/net/unixsock_posix.go +++ b/libgo/go/net/unixsock_posix.go @@ -13,7 +13,7 @@ import ( "syscall" ) -func unixSocket(net string, laddr, raddr *UnixAddr, mode string) (fd *netFD, err os.Error) { +func unixSocket(net string, laddr, raddr *UnixAddr, mode string) (fd *netFD, err error) { var proto int switch net { default: @@ -38,7 +38,7 @@ func unixSocket(net string, laddr, raddr *UnixAddr, mode string) (fd *netFD, err if raddr != nil { ra = &syscall.SockaddrUnix{Name: raddr.Name} } else if proto != syscall.SOCK_DGRAM || laddr == nil { - return nil, &OpError{Op: mode, Net: net, Error: errMissingAddress} + return nil, &OpError{Op: mode, Net: net, Err: errMissingAddress} } case "listen": @@ -47,7 +47,7 @@ func unixSocket(net string, laddr, raddr *UnixAddr, mode string) (fd *netFD, err } la = &syscall.SockaddrUnix{Name: laddr.Name} if raddr != nil { - return nil, &OpError{Op: mode, Net: net, Addr: raddr, Error: &AddrError{Error: "unexpected remote address", Addr: raddr.String()}} + return nil, &OpError{Op: mode, Net: net, Addr: raddr, Err: &AddrError{Err: "unexpected remote address", Addr: raddr.String()}} } } @@ -69,7 +69,7 @@ Error: if mode == "listen" { addr = laddr } - return nil, &OpError{Op: mode, Net: net, Addr: addr, Error: oserr} + return nil, &OpError{Op: mode, Net: net, Addr: addr, Err: oserr} } func sockaddrToUnix(sa syscall.Sockaddr) Addr { @@ -120,7 +120,7 @@ func (c *UnixConn) ok() bool { return c != nil && c.fd != nil } // Implementation of the Conn interface - see Conn for documentation. // Read implements the net.Conn Read method. -func (c *UnixConn) Read(b []byte) (n int, err os.Error) { +func (c *UnixConn) Read(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -128,7 +128,7 @@ func (c *UnixConn) Read(b []byte) (n int, err os.Error) { } // Write implements the net.Conn Write method. -func (c *UnixConn) Write(b []byte) (n int, err os.Error) { +func (c *UnixConn) Write(b []byte) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -136,7 +136,7 @@ func (c *UnixConn) Write(b []byte) (n int, err os.Error) { } // Close closes the Unix domain connection. -func (c *UnixConn) Close() os.Error { +func (c *UnixConn) Close() error { if !c.ok() { return os.EINVAL } @@ -165,7 +165,7 @@ func (c *UnixConn) RemoteAddr() Addr { } // SetTimeout implements the net.Conn SetTimeout method. -func (c *UnixConn) SetTimeout(nsec int64) os.Error { +func (c *UnixConn) SetTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -173,7 +173,7 @@ func (c *UnixConn) SetTimeout(nsec int64) os.Error { } // SetReadTimeout implements the net.Conn SetReadTimeout method. -func (c *UnixConn) SetReadTimeout(nsec int64) os.Error { +func (c *UnixConn) SetReadTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -181,7 +181,7 @@ func (c *UnixConn) SetReadTimeout(nsec int64) os.Error { } // SetWriteTimeout implements the net.Conn SetWriteTimeout method. -func (c *UnixConn) SetWriteTimeout(nsec int64) os.Error { +func (c *UnixConn) SetWriteTimeout(nsec int64) error { if !c.ok() { return os.EINVAL } @@ -190,7 +190,7 @@ func (c *UnixConn) SetWriteTimeout(nsec int64) os.Error { // SetReadBuffer sets the size of the operating system's // receive buffer associated with the connection. -func (c *UnixConn) SetReadBuffer(bytes int) os.Error { +func (c *UnixConn) SetReadBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -199,7 +199,7 @@ func (c *UnixConn) SetReadBuffer(bytes int) os.Error { // SetWriteBuffer sets the size of the operating system's // transmit buffer associated with the connection. -func (c *UnixConn) SetWriteBuffer(bytes int) os.Error { +func (c *UnixConn) SetWriteBuffer(bytes int) error { if !c.ok() { return os.EINVAL } @@ -213,7 +213,7 @@ func (c *UnixConn) SetWriteBuffer(bytes int) os.Error { // ReadFromUnix can be made to time out and return // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetReadTimeout. -func (c *UnixConn) ReadFromUnix(b []byte) (n int, addr *UnixAddr, err os.Error) { +func (c *UnixConn) ReadFromUnix(b []byte) (n int, addr *UnixAddr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -226,7 +226,7 @@ func (c *UnixConn) ReadFromUnix(b []byte) (n int, addr *UnixAddr, err os.Error) } // ReadFrom implements the net.PacketConn ReadFrom method. -func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { +func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err error) { if !c.ok() { return 0, nil, os.EINVAL } @@ -240,7 +240,7 @@ func (c *UnixConn) ReadFrom(b []byte) (n int, addr Addr, err os.Error) { // an error with Timeout() == true after a fixed time limit; // see SetTimeout and SetWriteTimeout. // On packet-oriented connections, write timeouts are rare. -func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (n int, err os.Error) { +func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -252,7 +252,7 @@ func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (n int, err os.Error) { } // WriteTo implements the net.PacketConn WriteTo method. -func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { +func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err error) { if !c.ok() { return 0, os.EINVAL } @@ -263,7 +263,7 @@ func (c *UnixConn) WriteTo(b []byte, addr Addr) (n int, err os.Error) { return c.WriteToUnix(b, a) } -func (c *UnixConn) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err os.Error) { +func (c *UnixConn) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err error) { if !c.ok() { return 0, 0, 0, nil, os.EINVAL } @@ -275,7 +275,7 @@ func (c *UnixConn) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAdd return } -func (c *UnixConn) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err os.Error) { +func (c *UnixConn) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err error) { if !c.ok() { return 0, 0, os.EINVAL } @@ -292,12 +292,12 @@ func (c *UnixConn) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (c *UnixConn) File() (f *os.File, err os.Error) { return c.fd.dup() } +func (c *UnixConn) File() (f *os.File, err error) { return c.fd.dup() } // DialUnix connects to the remote address raddr on the network net, // which must be "unix" or "unixgram". If laddr is not nil, it is used // as the local address for the connection. -func DialUnix(net string, laddr, raddr *UnixAddr) (c *UnixConn, err os.Error) { +func DialUnix(net string, laddr, raddr *UnixAddr) (c *UnixConn, err error) { fd, e := unixSocket(net, laddr, raddr, "dial") if e != nil { return nil, e @@ -315,7 +315,7 @@ type UnixListener struct { // ListenUnix announces on the Unix domain socket laddr and returns a Unix listener. // Net must be "unix" (stream sockets). -func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error) { +func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err error) { if net != "unix" && net != "unixgram" && net != "unixpacket" { return nil, UnknownNetworkError(net) } @@ -329,14 +329,14 @@ func ListenUnix(net string, laddr *UnixAddr) (l *UnixListener, err os.Error) { e1 := syscall.Listen(fd.sysfd, 8) // listenBacklog()); if e1 != 0 { closesocket(fd.sysfd) - return nil, &OpError{Op: "listen", Net: "unix", Addr: laddr, Error: os.Errno(e1)} + return nil, &OpError{Op: "listen", Net: "unix", Addr: laddr, Err: os.Errno(e1)} } return &UnixListener{fd, laddr.Name}, nil } // AcceptUnix accepts the next incoming call and returns the new connection // and the remote address. -func (l *UnixListener) AcceptUnix() (c *UnixConn, err os.Error) { +func (l *UnixListener) AcceptUnix() (c *UnixConn, err error) { if l == nil || l.fd == nil { return nil, os.EINVAL } @@ -350,7 +350,7 @@ func (l *UnixListener) AcceptUnix() (c *UnixConn, err os.Error) { // Accept implements the Accept method in the Listener interface; // it waits for the next call and returns a generic Conn. -func (l *UnixListener) Accept() (c Conn, err os.Error) { +func (l *UnixListener) Accept() (c Conn, err error) { c1, err := l.AcceptUnix() if err != nil { return nil, err @@ -360,7 +360,7 @@ func (l *UnixListener) Accept() (c Conn, err os.Error) { // Close stops listening on the Unix address. // Already accepted connections are not closed. -func (l *UnixListener) Close() os.Error { +func (l *UnixListener) Close() error { if l == nil || l.fd == nil { return os.EINVAL } @@ -387,7 +387,7 @@ func (l *UnixListener) Close() os.Error { func (l *UnixListener) Addr() Addr { return l.fd.laddr } // SetTimeout sets the deadline associated wuth the listener -func (l *UnixListener) SetTimeout(nsec int64) (err os.Error) { +func (l *UnixListener) SetTimeout(nsec int64) (err error) { if l == nil || l.fd == nil { return os.EINVAL } @@ -397,13 +397,13 @@ func (l *UnixListener) SetTimeout(nsec int64) (err os.Error) { // File returns a copy of the underlying os.File, set to blocking mode. // It is the caller's responsibility to close f when finished. // Closing c does not affect f, and closing f does not affect c. -func (l *UnixListener) File() (f *os.File, err os.Error) { return l.fd.dup() } +func (l *UnixListener) File() (f *os.File, err error) { return l.fd.dup() } // ListenUnixgram listens for incoming Unix datagram packets addressed to the // local address laddr. The returned connection c's ReadFrom // and WriteTo methods can be used to receive and send UDP // packets with per-packet addressing. The network net must be "unixgram". -func ListenUnixgram(net string, laddr *UnixAddr) (c *UDPConn, err os.Error) { +func ListenUnixgram(net string, laddr *UnixAddr) (c *UDPConn, err error) { switch net { case "unixgram": default: |