--- description: Go style matches .golangci.yaml (funlen, lll, revive, gocritic). globs: "**/*.go" alwaysApply: false --- # Go conventions Lint source of truth is `.golangci.yaml`. - `funlen`: 100 lines / 100 statements. Split EventLoop vs business vs worker. - `lll`: 240 columns. - `errcheck` / `govet` / `staticcheck` / `unused` must stay clean. - `gocritic` performance tag is on; avoid copying large structs in range. - `revive`: real error strings, context as first argument, no unused params. - Format with `goimports`; local prefix `spark-server`. - Hot path: pass `context.Context`, never `context.TODO()`. - Domain errors live in `internal/pkg/errs` and are mapped at Transport. ```go // BAD: EventLoop does I/O func (s *Server) OnTraffic(c gnet.Conn) gnet.Action { db.Create(msg) // forbidden return gnet.None } // GOOD func (s *Server) OnTraffic(c gnet.Conn) gnet.Action { _ = s.pool.Submit(ctx, func() { s.handleBusiness(frame) }) return gnet.None } ```