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:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user