← ClaudeAtlas

go-architectlisted

Go 1.26 architectural standards — memory-aligned structs, typed enums, interface design, goroutine safety, iterators, idiomatic errors, sqlx + //go:embed SQL pattern. Use when writing, reviewing, or scaffolding Go code.
ralvarezdev/ralvaskills · ★ 2 · Code & Development · score 75
Install: claude install-skill ralvarezdev/ralvaskills
# Go Architecture & Domain Modeling Targets **Go 1.26**. See [STACK.md](STACK.md) for pinned dependency versions. ## 1. Constants & Enums - **Enums:** Custom types with `iota` and an implemented `String()` method. Avoid bare primitives. Use `1 << iota` for bitmasks. - **Errors:** Export package-level sentinel errors (`var ErrNotFound = ...`) for `errors.Is()`. Use `errors.Join` to aggregate multiple errors. - **Grouping:** When a file declares multiple `type`, `const`, or `var` at package level, consolidate each kind into a single parenthesized block (`type (...)`, `const (...)`, `var (...)`) rather than repeating the keyword. Keep unrelated groups separated by a blank line inside the block. ## 2. Structures & Memory - **Design:** Explicit struct tags, standard audit fields, composition via embedding. - **Optimization:** Order fields largest → smallest to minimize padding. - **Semantics:** Pointers for mutation or mutex-protected state; values for small, immutable payloads. - **Validation:** `Validate() error` for structs taking external input; tag-based validation via `go-playground/validator`. - **Ordering:** Use `cmp` (`cmp.Compare[T]`, `cmp.Or`, `cmp.Less`) as the default ordering toolkit. ## 3. Instantiation - **Constructors:** Always provide `New...` to initialize maps, slices, channels safely. - **Configuration:** Functional Options pattern for complex setup; never large config structs passed by value. ## 4. Interfaces - **Design:** Define interfaces where the