1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:50:21 -07:00

net: make Dial correctly return nil on error.

R=rsc
CC=golang-dev
https://golang.org/cl/181135
This commit is contained in:
Roger Peppe 2010-01-05 09:20:02 -08:00 committed by Russ Cox
parent 30e5ed249d
commit 0281b71580

View File

@ -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: