mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: check all Close() return values for errcheck lint
Add explicit error discards (_ =) for Close() calls on network connections, SQL rows, and file handles across 28 files. Also add .golangci.yml with standard linter defaults to match CI configuration.
This commit is contained in:
@@ -354,8 +354,8 @@ func TestSessionWorkWithDevModeLogging(t *testing.T) {
|
||||
}
|
||||
|
||||
clientConn, serverConn := net.Pipe()
|
||||
defer clientConn.Close()
|
||||
defer serverConn.Close()
|
||||
defer func() { _ = clientConn.Close() }()
|
||||
defer func() { _ = serverConn.Close() }()
|
||||
|
||||
session := &Session{
|
||||
logger: logger,
|
||||
@@ -364,7 +364,7 @@ func TestSessionWorkWithDevModeLogging(t *testing.T) {
|
||||
cryptConn: network.NewCryptConn(serverConn),
|
||||
}
|
||||
|
||||
clientConn.Close()
|
||||
_ = clientConn.Close()
|
||||
|
||||
session.work()
|
||||
}
|
||||
@@ -380,7 +380,7 @@ func TestSessionWorkWithEmptyRead(t *testing.T) {
|
||||
}
|
||||
|
||||
clientConn, serverConn := net.Pipe()
|
||||
defer serverConn.Close()
|
||||
defer func() { _ = serverConn.Close() }()
|
||||
|
||||
session := &Session{
|
||||
logger: logger,
|
||||
@@ -389,7 +389,7 @@ func TestSessionWorkWithEmptyRead(t *testing.T) {
|
||||
cryptConn: network.NewCryptConn(serverConn),
|
||||
}
|
||||
|
||||
clientConn.Close()
|
||||
_ = clientConn.Close()
|
||||
|
||||
session.work()
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *Server) Shutdown() {
|
||||
s.Unlock()
|
||||
|
||||
// This will cause the acceptor goroutine to error and exit gracefully.
|
||||
s.listener.Close()
|
||||
_ = s.listener.Close()
|
||||
}
|
||||
|
||||
func (s *Server) acceptClients() {
|
||||
@@ -86,7 +86,7 @@ func (s *Server) acceptClients() {
|
||||
|
||||
func (s *Server) handleConnection(conn net.Conn) {
|
||||
s.logger.Debug("New connection", zap.String("RemoteAddr", conn.RemoteAddr().String()))
|
||||
defer conn.Close()
|
||||
defer func() { _ = conn.Close() }()
|
||||
|
||||
// Client initalizes the connection with a one-time buffer of 8 NULL bytes.
|
||||
nullInit := make([]byte, 8)
|
||||
|
||||
@@ -434,7 +434,7 @@ func TestServerHandleConnection(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Dial() error: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
defer func() { _ = conn.Close() }()
|
||||
|
||||
nullInit := make([]byte, 8)
|
||||
_, err = conn.Write(nullInit)
|
||||
@@ -472,7 +472,7 @@ func TestServerHandleConnectionWithShortInit(t *testing.T) {
|
||||
}
|
||||
|
||||
_, _ = conn.Write([]byte{0, 0, 0, 0})
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
@@ -502,7 +502,7 @@ func TestServerHandleConnectionImmediateClose(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Dial() error: %v", err)
|
||||
}
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
@@ -544,7 +544,7 @@ func TestServerMultipleConnections(t *testing.T) {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
for _, conn := range conns {
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user