From 0281b715804ce5e4040729d904d41b0da0969ca5 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Tue, 5 Jan 2010 09:20:02 -0800 Subject: [PATCH] net: make Dial correctly return nil on error. R=rsc CC=golang-dev https://golang.org/cl/181135 --- src/pkg/net/net.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 5e6ba8c201..2f145a72cb 100644 --- a/src/pkg/net/net.go +++ b/src/pkg/net/net.go @@ -134,7 +134,11 @@ func Dial(net, laddr, raddr string) (c Conn, err os.Error) { goto Error } } - return DialTCP(net, la, ra) + c, err := DialTCP(net, la, ra) + if err != nil { + return nil, err + } + return c, nil case "udp", "udp4", "upd6": var la, ra *UDPAddr if laddr != "" { @@ -147,7 +151,11 @@ func Dial(net, laddr, raddr string) (c Conn, err os.Error) { goto Error } } - return DialUDP(net, la, ra) + c, err := DialUDP(net, la, ra) + if err != nil { + return nil, err + } + return c, nil case "unix", "unixgram": var la, ra *UnixAddr if raddr != "" { @@ -160,7 +168,11 @@ func Dial(net, laddr, raddr string) (c Conn, err os.Error) { goto Error } } - return DialUnix(net, la, ra) + c, err = DialUnix(net, la, ra) + if err != nil { + return nil, err + } + return c, nil } err = UnknownNetworkError(net) Error: