style: check error returns flagged by errcheck linter

golangci-lint's errcheck rule requires explicit handling of error
return values from Close, Write, and Logout calls. Use blank
identifier assignment for cleanup paths where errors are
intentionally discarded.
This commit is contained in:
Houmgaor
2026-02-20 21:22:01 +01:00
parent 458d8c9397
commit e899a2f790
8 changed files with 34 additions and 34 deletions

View File

@@ -58,17 +58,17 @@ func Login(signAddr, username, password string) (*LoginResult, error) {
loginPkt := protocol.BuildLoginPacket(ack, charID, sign.TokenID, sign.TokenString)
fmt.Printf("[channel] Sending MSG_SYS_LOGIN (charID=%d, ackHandle=%d)...\n", charID, ack)
if err := ch.SendPacket(loginPkt); err != nil {
ch.Close()
_ = ch.Close()
return nil, fmt.Errorf("channel send login: %w", err)
}
resp, err := ch.WaitForAck(ack, 10*time.Second)
if err != nil {
ch.Close()
_ = ch.Close()
return nil, fmt.Errorf("channel login ack: %w", err)
}
if resp.ErrorCode != 0 {
ch.Close()
_ = ch.Close()
return nil, fmt.Errorf("channel login failed: error code %d", resp.ErrorCode)
}
fmt.Printf("[channel] Login ACK received (error=%d, %d bytes data)\n",

View File

@@ -10,7 +10,7 @@ import (
func Logout(ch *protocol.ChannelConn) error {
fmt.Println("[logout] Sending MSG_SYS_LOGOUT...")
if err := ch.SendPacket(protocol.BuildLogoutPacket()); err != nil {
ch.Close()
_ = ch.Close()
return fmt.Errorf("logout send: %w", err)
}
return ch.Close()