From 97f5d8a91fa3203b5d6da46fb0e64211584f9334 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 23 Feb 2026 11:47:34 -0800 Subject: [PATCH] styleguide: add rule against type-only packages Types should be defined alongside the implementations that use them, not in separate 'types' or 'domain' packages. This avoids awkward import aliases and keeps types close to their usage. --- prompts/CODE_STYLEGUIDE_GO.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prompts/CODE_STYLEGUIDE_GO.md b/prompts/CODE_STYLEGUIDE_GO.md index f859589..4cc8e93 100644 --- a/prompts/CODE_STYLEGUIDE_GO.md +++ b/prompts/CODE_STYLEGUIDE_GO.md @@ -227,6 +227,14 @@ last_modified: 2026-02-22 } ``` +1. Do not create packages just to hold types (e.g. `types`, `domain`, + `models` that contain only type definitions). Define types alongside the + implementations that use them. A type-only package is a sign that the types + are in the wrong place — move them to the package that actually operates on + them. This also avoids awkward import aliases (e.g. + `domaintypes "myapp/internal/domain"`) which are a code smell indicating + poor package naming. + 1. Define your struct types near their constructors. 1. Define your interface types near the functions that use them, or if you have -- 2.45.2