diff options
author | Roger Peppe <rogpeppe@gmail.com> | 2010-01-05 09:20:02 -0800 |
---|---|---|
committer | Roger Peppe <rogpeppe@gmail.com> | 2010-01-05 09:20:02 -0800 |
commit | a630bd236bfd67500d3ab70194aa161f2f2670eb (patch) | |
tree | f0b06c0f22658aed13b2e7b5010d17eead23dab0 /src/pkg/net | |
parent | 8711d291cfde1e224428fdbc8cc524c758319d36 (diff) | |
download | golang-a630bd236bfd67500d3ab70194aa161f2f2670eb.tar.gz |
net: make Dial correctly return nil on error.
R=rsc
CC=golang-dev
http://codereview.appspot.com/181135
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/net')
-rw-r--r-- | src/pkg/net/net.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 5e6ba8c20..2f145a72c 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: |