Handle error on response body close to prevent panic

This commit is contained in:
tsosunchia committed 2025-10-29 13:03:35 +08:00
1 parent dea2f7bf45
commit 3a09d28ea3
1 file changed
+4 -1
+4 -1
View File
@@ -133,7 +133,10 @@ func checkLatency(domain string, ip string, port string) {
// 防止后续对 nil Body 的读写导致 panic
return
}
defer resp.Body.Close()
defer func() {
// 明确忽略关闭时的错误,HTTP 客户端此时已经读完正文
_ = resp.Body.Close()
}()
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {