Make lint happy

Address the errcheck lint error by checking the return from conn.Close()
This commit is contained in:
Phi 2023-08-08 12:49:04 +02:00
parent b6ba3b23bb
commit c4798a604a

View File

@ -779,11 +779,16 @@ func extractRoutableIP(timeout time.Duration) (string, error) {
minerIP, _ := maddr.ValueForProtocol(multiaddr.P_IP6)
minerPort, _ := maddr.ValueForProtocol(multiaddr.P_TCP)
conn, err := net.DialTimeout("tcp", "["+minerIP+"]:"+minerPort, timeout) // Enclose IPv6 address in brackets
conn, err := net.DialTimeout("tcp", minerIP+":"+minerPort, timeout)
if err != nil {
return "", err
}
defer conn.Close()
defer func() {
if cerr := conn.Close(); cerr != nil {
log.Errorf("Error closing connection: %v", cerr)
}
}()
localAddr := conn.LocalAddr().(*net.TCPAddr)
return localAddr.IP.String(), nil