From 88411547d4d8fca47403ce6518e0c170d8cc8282 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Thu, 15 Aug 2013 05:53:53 +0900 Subject: [PATCH] net: simplify dial R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12884044 --- src/pkg/net/dial.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pkg/net/dial.go b/src/pkg/net/dial.go index b6ed830511f..8df4f778499 100644 --- a/src/pkg/net/dial.go +++ b/src/pkg/net/dial.go @@ -146,30 +146,26 @@ func (d *Dialer) Dial(network, address string) (Conn, error) { return resolveAndDial(network, address, d.LocalAddr, d.deadline()) } -func dial(net, addr string, la, ra Addr, deadline time.Time) (c Conn, err error) { +func dial(net, addr string, la, ra Addr, deadline time.Time) (Conn, error) { if la != nil && la.Network() != ra.Network() { return nil, &OpError{Op: "dial", Net: net, Addr: ra, Err: errors.New("mismatched local address type " + la.Network())} } switch ra := ra.(type) { case *TCPAddr: la, _ := la.(*TCPAddr) - c, err = dialTCP(net, la, ra, deadline) + return dialTCP(net, la, ra, deadline) case *UDPAddr: la, _ := la.(*UDPAddr) - c, err = dialUDP(net, la, ra, deadline) + return dialUDP(net, la, ra, deadline) case *IPAddr: la, _ := la.(*IPAddr) - c, err = dialIP(net, la, ra, deadline) + return dialIP(net, la, ra, deadline) case *UnixAddr: la, _ := la.(*UnixAddr) - c, err = dialUnix(net, la, ra, deadline) + return dialUnix(net, la, ra, deadline) default: - err = &OpError{Op: "dial", Net: net, Addr: ra, Err: &AddrError{Err: "unexpected address type", Addr: addr}} + return nil, &OpError{Op: "dial", Net: net, Addr: ra, Err: &AddrError{Err: "unexpected address type", Addr: addr}} } - if err != nil { - return nil, err - } - return } type stringAddr struct {