diff --git a/prompts/CODE_STYLEGUIDE_GO.md b/prompts/CODE_STYLEGUIDE_GO.md index d431fed..58a72ff 100644 --- a/prompts/CODE_STYLEGUIDE_GO.md +++ b/prompts/CODE_STYLEGUIDE_GO.md @@ -157,13 +157,14 @@ last_modified: 2026-02-22 `server`. `util` is banned. 1. Constructors **must** take a `Params` struct (or `ThingParams` when - `NewThing()` is used). Positional arguments for constructors are an endless - source of bugs — they make call sites unreadable, invite wrong-order errors - that the compiler can't catch when types coincide, and force every caller to - update when a new field is added. The only exception is a constructor that - takes exactly one argument whose meaning is obvious from context (e.g. - `New(ctx)` or `FromBytes(b)`). Two or more arguments → use a Params struct, - no exceptions. + `NewThing()` is used), even for a single argument. Named fields in a Params + struct are always clearer than positional arguments. Positional arguments + for constructors are an endless source of bugs — they make call sites + unreadable, invite wrong-order errors that the compiler can't catch when + types coincide, and force every caller to update when a new field is added. + The only exception is when the single argument is stupidly obvious from + context — e.g. `featureflag.New(true)` or `thing.NewFromReader(r)`. When in + doubt, use a Params struct. 1. Use `context.Context` for all functions that need it. If you don't need it, you can pass `context.Background()`. Anything long-running should get and