Skip to content

Commit c35eb81

Browse files
tcping: fix panic
1 parent 6a21e1b commit c35eb81

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tool/tcping.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ func TCPing(q *TCPingQ) (*TCPingP, error) {
7676
Success: err == nil,
7777
Latency: float64(time.Since(now)) / float64(time.Millisecond),
7878
})
79-
_ = conn.Close()
79+
if conn != nil {
80+
_ = conn.Close()
81+
}
8082
timer.Stop()
8183
cancel()
8284
time.Sleep(time.Duration(q.Interval) * time.Millisecond)

0 commit comments

Comments
 (0)