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