$npx -y skills add fusengine/agents --skill go-architectureStructure Go 1.22+ services — standard cmd/internal layout, constructor-based dependency injection, HTTP routing (net/http ServeMux vs chi vs echo/gin/fiber), and type-safe database access with sqlc + pgx. Use when laying out a new Go project, choosing a router or DB layer, or wi
| 1 | # Go Architecture |
| 2 | |
| 3 | Opinionated, 2026-current guidance for structuring Go backend services. Favors the |
| 4 | standard library and small, composable libraries over heavy frameworks. |
| 5 | |
| 6 | **Use when:** |
| 7 | - Laying out a new Go module or service (directory structure, `cmd/`, `internal/`) |
| 8 | - Choosing an HTTP router (stdlib `net/http` ServeMux, chi, echo/gin/fiber) |
| 9 | - Choosing a database layer (sqlc + pgx, GORM) or wiring queries |
| 10 | - Wiring dependencies (constructors, DI without a framework) |
| 11 | - Reviewing an existing Go service for structural / architectural issues |
| 12 | |
| 13 | **Do NOT use for:** |
| 14 | - Writing tests, benchmarks, fuzzing, coverage — use `go-testing-quality` |
| 15 | - SOLID line-limit / interface-placement enforcement — use `fuse-solid:solid-go` |
| 16 | - Non-Go backends (Laravel, Next.js, Rust) — use the matching expert |
| 17 | - Frontend / UI work — use `fuse-design` or a framework expert |
| 18 | |
| 19 | --- |
| 20 | |
| 21 | ## Decision Map |
| 22 | |
| 23 | | Question | Load | |
| 24 | |----------|------| |
| 25 | | Where do files/packages go? | [project-layout.md](references/project-layout.md) | |
| 26 | | Which HTTP router? How do I route? | [http-routing.md](references/http-routing.md) | |
| 27 | | How do I talk to the database? | [database-access.md](references/database-access.md) | |
| 28 | | How do I wire dependencies? | [dependency-injection.md](references/dependency-injection.md) | |
| 29 | | I need a full working example | [templates/rest-service.md](references/templates/rest-service.md) | |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Core Principles (2026) |
| 34 | |
| 35 | 1. **Standard library first.** Since Go 1.22 the `net/http.ServeMux` supports |
| 36 | method matching and path wildcards (`GET /posts/{id}`, `req.PathValue("id")`). |
| 37 | Most services no longer need a routing framework. |
| 38 | Source: https://go.dev/blog/routing-enhancements |
| 39 | 2. **`internal/` is the default home for service logic.** A server binary is |
| 40 | self-contained; keep packages under `internal/` and binaries under `cmd/`. |
| 41 | There is no official `pkg/` requirement — do not cargo-cult it. |
| 42 | Source: https://go.dev/doc/modules/layout |
| 43 | 3. **Constructor injection, no DI framework by default.** Pass dependencies as |
| 44 | interface parameters to `New…` constructors; wire them in `main`. |
| 45 | 4. **Type-safe SQL is the 2026 default.** `sqlc` generates idiomatic Go from raw |
| 46 | SQL; run it on top of the `pgx` driver for PostgreSQL. GORM still works but is |
| 47 | in relative decline for new services — see database-access.md for the nuance. |
| 48 | Sources: https://docs.sqlc.dev + https://pkg.go.dev/github.com/jackc/pgx/v5 |
| 49 | |
| 50 | --- |
| 51 | |
| 52 | ## Workflow |
| 53 | |
| 54 | 1. **Explore** the existing tree first (do not assume layout). |
| 55 | 2. **Load** the relevant reference from the Decision Map above. |
| 56 | 3. **Cross-check** the version-sensitive claims (router, sqlc/pgx) against the |
| 57 | source URLs before writing code — APIs move. |
| 58 | 4. **Scaffold** from [templates/rest-service.md](references/templates/rest-service.md) |
| 59 | when starting fresh. |
| 60 | 5. **Keep files small** and interfaces separated (defer to `fuse-solid:solid-go`). |
| 61 | 6. **Validate** with `go-testing-quality` + sniper after any code change. |
| 62 | |
| 63 | --- |
| 64 | |
| 65 | ## Boundaries (cross-referenced, not copied) |
| 66 | |
| 67 | The community skill set at `github.com/samber/cc-skills-golang` covers overlapping |
| 68 | Go territory. This skill deliberately scopes to **architecture / structure / |
| 69 | routing / DB wiring** and hands testing off to `go-testing-quality`. When in |
| 70 | doubt about which skill owns a topic, prefer the more specific one. |