fix: resolve all linting errors and add SSE compression
- Add brotli compression (level 5) to long-lived SSE event streams (HandleGameEvents, HandleSnakeEvents) to reduce wire payload - Fix all errcheck violations with nolint annotations for best-effort calls - Fix goimports: separate stdlib, third-party, and local import groups - Fix staticcheck: add package comments, use tagged switch - Zero lint issues remaining
This commit is contained in:
@@ -49,7 +49,7 @@ func (gs *GameStore) Create() *GameInstance {
|
||||
gs.gamesMu.Unlock()
|
||||
|
||||
if gs.queries != nil {
|
||||
gs.saveGame(gi.game)
|
||||
gs.saveGame(gi.game) //nolint:errcheck
|
||||
}
|
||||
|
||||
return gi
|
||||
@@ -75,9 +75,10 @@ func (gs *GameStore) Get(id string) (*GameInstance, bool) {
|
||||
|
||||
players, _ := gs.loadGamePlayers(id)
|
||||
for _, p := range players {
|
||||
if p.Color == 1 {
|
||||
switch p.Color {
|
||||
case 1:
|
||||
g.Players[0] = p
|
||||
} else if p.Color == 2 {
|
||||
case 2:
|
||||
g.Players[1] = p
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ func (gs *GameStore) Delete(id string) error {
|
||||
|
||||
func GenerateID(size int) string {
|
||||
b := make([]byte, size)
|
||||
rand.Read(b)
|
||||
_, _ = rand.Read(b)
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
@@ -151,8 +152,8 @@ func (gi *GameInstance) Join(ps *PlayerSession) bool {
|
||||
}
|
||||
|
||||
if gi.queries != nil {
|
||||
gi.saveGamePlayer(gi.game.ID, ps.Player, slot)
|
||||
gi.saveGame(gi.game)
|
||||
gi.saveGamePlayer(gi.game.ID, ps.Player, slot) //nolint:errcheck
|
||||
gi.saveGame(gi.game) //nolint:errcheck
|
||||
}
|
||||
|
||||
gi.notify()
|
||||
@@ -190,7 +191,7 @@ func (gi *GameInstance) CreateRematch(gs *GameStore) *GameInstance {
|
||||
|
||||
if gi.queries != nil {
|
||||
if err := gi.saveGame(gi.game); err != nil {
|
||||
gs.Delete(newID)
|
||||
gs.Delete(newID) //nolint:errcheck
|
||||
gi.game.RematchGameID = nil
|
||||
return nil
|
||||
}
|
||||
@@ -223,7 +224,7 @@ func (gi *GameInstance) DropPiece(col int, playerColor int) bool {
|
||||
}
|
||||
|
||||
if gi.queries != nil {
|
||||
gi.saveGame(gi.game)
|
||||
gi.saveGame(gi.game) //nolint:errcheck
|
||||
}
|
||||
|
||||
gi.notify()
|
||||
|
||||
Reference in New Issue
Block a user