--- description: Idiomatic Go style (Effective Go + Code Review Comments) globs: ["**/*.go"] alwaysApply: true --- - Format with `gofmt`; tabs for indentation, no parentheses on `if`/`for`/`switch`. - `MixedCaps`/`mixedCaps`, never underscores. Capitalized first letter = exported. - Package names: short, lower-case, single word. No `util`/`common`/`misc`; don't stutter. - Getters drop `Get` (`Owner()`/`SetOwner()`). One-method interfaces use the `-er` suffix. - Initialisms keep consistent case: `ServeHTTP`, `appID`, `URL`. - Error strings lower-case, no trailing punctuation; prefix with the operation/package. - Handle every error — return, handle, or panic. Never discard with `_`. Don't `panic` for normal flow. - Avoid in-band errors; return an extra `error` or `ok bool`. - Check errors early and return; keep the happy path at minimal indentation; drop the `else` after a terminating `if`. - Keep interfaces small. Accept interfaces, return concrete types. Define them in the consuming package, not "for mocking". - "Do not communicate by sharing memory; instead, share memory by communicating" — prefer channels and `select`. - Pass `context.Context` as the first parameter; prefer synchronous functions. - Receiver names: consistent 1–2 letter abbreviation of the type, never `me`/`this`/`self`. - Pointer receiver to mutate / large structs / `sync.Mutex`; value receiver for small immutable types; when in doubt, pointer. - `defer` cleanup after acquiring the resource. `new(T)` for zeroed `*T`, `make` for slices/maps/channels. - Doc comments: full sentences starting with the name, ending with a period. - Use `crypto/rand` for keys/secrets, never `math/rand`.