mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-06 16:18:00 +08:00
Appease/placate/mollify the linter
- Unnecessarily handle the error in the `defer` - Do a better comparison of the address-in-use error
This commit is contained in:
6
main.go
6
main.go
@@ -165,7 +165,9 @@ func readFromTCP(tcpListener *net.TCPListener, x *xip.Xip, quiet bool) {
|
|||||||
addr, port, err := net.SplitHostPort(remoteAddrPort)
|
addr, port, err := net.SplitHostPort(remoteAddrPort)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer tcpConn.Close()
|
defer func(tcpConn *net.TCPConn) {
|
||||||
|
_ = tcpConn.Close()
|
||||||
|
}(tcpConn)
|
||||||
response, logMessage, err := x.QueryResponse(query, net.ParseIP(addr))
|
response, logMessage, err := x.QueryResponse(query, net.ParseIP(addr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
@@ -256,7 +258,7 @@ func isErrorAddressAlreadyInUse(err error) bool {
|
|||||||
if !errors.As(eOsSyscall, &errErrno) {
|
if !errors.As(eOsSyscall, &errErrno) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if errErrno == syscall.EADDRINUSE {
|
if errors.Is(errErrno, syscall.EADDRINUSE) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const WSAEADDRINUSE = 10048
|
const WSAEADDRINUSE = 10048
|
||||||
|
Reference in New Issue
Block a user