1. Remove use of defer for the unlock because it make hold the mutex longer than necessary
2. Remove shadowed err var on L166
client := s.Clients[uint16(clientID)]
client := s.Clients[uint16(clientID)]
if client == nil {
return fmt.Errorf("invalid client id %v", *t.clientID)
}
if client == nil {
return fmt.Errorf("invalid client id %v", *t.clientID)
}
- if _, err := client.Connection.Write(b); err != nil {
+ _, err = client.Connection.Write(b)
+ if err != nil {