lib/dialer: Preserve nilness in error handling (fixes #6368) (#6369)

Also the call site where it shouldn't anyway be looking at the conn when
the err is non-nil.
This commit is contained in:
Jakob Borg
2020-02-26 13:16:18 +01:00
committed by GitHub
parent cb624dbf5d
commit 4e4b9a872a
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ func TCPPing(ctx context.Context, address string) (time.Duration, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
conn, err := dialer.DialContext(ctx, "tcp", address)
if conn != nil {
if err == nil {
conn.Close()
}
return time.Since(start), err