go-architecture

Structure Go backend services with cmd/internal layout, stdlib routing, and sqlc database access.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill go-architecture-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: go-architecture
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/go-expert/skills/go-architecture
Command: npx skills add https://github.com/fusengine/kimi-code --skill go-architecture-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Choosing a project layout, HTTP router, database layer, and dependency wiring for a Go service involves many competing options, and outdated advice leads to over-engineered structures. This Skill provides opinionated, current guidance for structuring Go 1.22+ backend services so you make consistent architectural decisions. ## Core Features & Use Cases - Project Layout Guidance: Apply the official cmd/internal module layout, avoid cargo-culted pkg/ directories, and name packages cohesively. - Router and Database Selection: Decide between stdlib net/http ServeMux, chi, echo/gin/fiber, and between sqlc + pgx versus GORM, with honest trade-offs. - Dependency Injection Patterns: Wire dependencies with constructor injection and narrow consumer-defined interfaces, no DI framework by default. - Use Case: You are starting a new Go REST API backed by PostgreSQL. Load this Skill to scaffold the cmd/api + internal/ tree, route with the Go 1.22 ServeMux, and wire a pgx pool through constructors using the included working template. ## Quick Start Ask the agent to scaffold a new Go REST service with a PostgreSQL backend using the go-architecture skill.

Frequently Asked Questions about go-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Go backend project?▼

Place binaries under cmd/<name>/main.go and service logic under internal/, which the Go toolchain prevents other modules from importing. Keep main thin as a composition root, isolate generated database code in a store package, and avoid adding a pkg/ directory out of habit.

Which HTTP router should I use for a Go service?▼

Start with the stdlib net/http ServeMux, which since Go 1.22 supports method matching and path wildcards like GET /posts/{id}. Move to chi when you need route groups and middleware while staying net/http-native; choose echo or gin only if you want their batteries, and fiber only for measured throughput needs.

sqlc vs GORM: which is better for PostgreSQL in Go?▼

sqlc with the pgx driver is the current default for new services because it generates type-safe Go from raw SQL without reflection or hidden queries. GORM remains viable for rapid CRUD scaffolding or teams already fluent in it, so migrate only with cause.

Does Go need a dependency injection framework?▼

No, idiomatic Go uses constructor injection where each component accepts its dependencies as interface parameters and main wires them explicitly. Add google/wire for compile-time codegen only when manual wiring genuinely hurts, and prefer it over runtime containers like uber/fx.

Is the pgx connection pool safe for concurrent use?▼

A pgxpool.Pool is safe for concurrent use and should be shared across handlers, while a single *pgx.Conn is not concurrency-safe. Create the pool with pgxpool.New in main and pass it to your store constructors.

When should I not use this Go architecture guidance?▼

Do not use it for concurrency patterns with goroutines and channels, general language idioms, or testing and benchmarking, which belong to separate skills. It also does not apply to non-Go backends like Laravel, Next.js, or Rust.