Go Module
Build backend modules with clear layer boundaries.
Module shape
internal/<module>/handler.go, service.go, queries.sql, tests.
Procedure
- •Confirm endpoint contract exists in
api.yaml. - •Update/create
internal/<module>/queries.sql. - •Run
make generate-sqlc. - •Implement
service.go:- •business logic only
- •no
net/httptypes - •wrap errors with context
- •Implement
handler.go:- •parse/validate/delegate/respond
- •use
pkg/httputilresponse helpers only
- •Register routes in module route wiring.
- •Add tests:
- •handler happy path + error paths
- •service logic + edge cases
- •Run
make testandmake lint.
Rules
- •Handlers contain no business logic.
- •Services contain no HTTP concerns.
- •All list endpoints must be paginated.
- •Never hand-edit
internal/store/*.go.