HTTP server
net/http
Standard handlers and request contexts minimize routing infrastructure.
Limits: Set request/body limits, deadlines and graceful shutdown; middleware and authorization remain application work.
HTTP APIs and backend services with a straightforward binary deployment.
net/http · pgx · sqlc · PostgreSQL
These recipes and dependency combinations need checking in your actual project before you rely on them.
Paste the guide address into your agent chat, together with what you want to build.
Use cases: APIs; control planes; concurrent network services; background workers.
Generator documentation reviewed: 2026-10-18. Evidence: documentation-reviewed; commands not executed.
Use when: A new Go service has no go.mod; preserve an existing module rather than reinitializing it.
Working directory: /path/to/workspace (existing local source parent)
Create an empty project directory.
mkdir projectWorking directory: /path/to/workspace/project
Create go.mod using the real module path.
go mod init example.com/projectUse when: Only when sqlc is selected and schema, annotated queries and sqlc.yaml/sqlc.json have been written.
Working directory: /path/to/workspace/project (sqlc configuration directory; selected sqlc installed)
Generate typed query access from owned SQL inputs.
sqlc generateUse when: Only when goose owns migrations for this database.
Working directory: /path/to/workspace/project (selected goose installed)
Create a timestamped migration to edit and review.
goose -dir migrations create initial sqlUse when: Only when the optional templ UI has been selected and .templ source exists.
Working directory: /path/to/workspace/project (selected templ CLI installed)
Generate Go component code from .templ sources.
templ generateUse when: Only when GoReleaser is selected for this application and no release configuration exists.
Working directory: /path/to/workspace/project (module root; selected GoReleaser installed)
Generate .goreleaser.yaml.
goreleaser initWorking directory: /path/to/workspace/project
Validate the reviewed release configuration.
goreleaser checkChoose the tools your application needs. The brief includes your selections, their purpose and their limits; the complete guide keeps all recommendations and sources.
net/http
Standard handlers and request contexts minimize routing infrastructure.
Limits: Set request/body limits, deadlines and graceful shutdown; middleware and authorization remain application work.
templ + HTMX
Compiled components and HTML-fragment updates suit forms and dashboards.
Limits: Generation adds a build step; advanced client state still needs browser-side design and testing.
PostgreSQL + pgx + sqlc + goose
Visible SQL, generated typed access and one migration owner.
Limits: Generators do not prove query efficiency; review transaction boundaries, pool budgets and online migration behavior. Never mix migration owners.
Typed settings loaded with os.LookupEnv
Explicit startup validation and standard structured logs.
Limits: Define precedence; reject malformed required values; redact secrets. Environment access alone is not validation or secret management.
log/slog
Explicit startup validation and standard structured logs.
Limits: Define precedence; reject malformed required values; redact secrets. Environment access alone is not validation or secret management.
testing; go vet; race detector; govulncheck
Standard toolchain feedback plus exercised concurrency and known-vulnerability checks.
Limits: Race detector requires supported target/toolchain and exercised code; no scanner proves absence of vulnerabilities.
httptest + real disposable PostgreSQL
Exercise protocols and actual SQL/migrations.
Limits: Database tests need an isolated database; mocks cannot establish PostgreSQL semantics.
River for PostgreSQL-backed jobs
Transactional enqueueing ties work to committed business data.
Limits: External effects need idempotency. Default resumable checkpoints may be lost on crash; use transactional checkpoints where required. Inspect Pro feature boundaries.
Go build binary in a supervised process or container; GoReleaser for releases
Small explicit runtime boundary; release automation builds target artifacts.
Limits: Target OS/architecture, libc/cgo, CA certificates, timezone data and signing need explicit verification. Snapshot builds are not publication.
go-oidc + existing OIDC provider
Provider discovery and ID-token verification support owned login sessions
Limits: Use v3 module; configure issuer/client, OAuth callback state and session lifecycle. go-oidc verifies ID tokens; API access-token validation follows the provider contract. Authorization stays near data.
go-mail + project-selected SMTP provider
Typed mail construction and SMTP transport support application messages
Limits: Configure TLS, sender credentials and timeouts; send required mail through durable jobs with duplicate protection. Validate chosen async/runtime features in Rust; delivery receipts and bounces need provider handling.
AWS SDK for Go S3 client
Durable object storage avoids dependence on service-local disk
Limits: Configure runtime credentials, region and least-privilege bucket access; authorize object keys and uploads, bound size/concurrency and define retention. Test multipart cleanup and selected provider compatibility.
coder/websocket
WebSocket support fits bidirectional connected clients
Limits: Enable the documented module/feature; authorize handshake and every protected message, bound queues/message size and implement heartbeat/shutdown. Socket delivery is not durable history; define reconnect/resync.
Build with the stack’s strengths
Recommendation: a Go HTTP process owns request admission and cancellation, domain packages own invariants, and a bounded SQL connection pool provides parallel database access. Durable jobs have their own persisted queue and worker lifecycle. Goroutines and buffered channels are concurrency mechanisms; graceful drain does not turn them into a recoverable queue.
Version scope: Go 1.27 release documentation and current net/http/context APIs; sqlc latest transaction guide with pgx/v5; River current documentation, PostgreSQL composition. Resolve and record Go toolchain, sqlc, pgx and River versions in go.mod/go.sum and tool configuration before implementation. Official release notes identify Go 1.27 as the August 2026 release; this research does not qualify a lockfile or patch-version/security support. · Reviewed 2026-10-11 · Evidence: documentation-reviewed · Source: inputs/research/migrations-systems.json
For an existing application
These are documented options and proposed checks. Inspect the actual source application before adopting a transition.
Inventory the old schema, isolation, identifiers, null handling, timestamps and transaction invariants before changing language or driver.
Recommendation: let the old application own migrations while Go accesses backward-compatible columns through sqlc; route writes for one domain/cohort to one owner. Expand schema before either runtime needs it.
Recommendation: sqlc plus pgx/v5 or database/sql, a shared bounded pool and explicit transaction-scoped queries. Keep the existing database if its guarantees fit; PostgreSQL replacement is a separate migration.
Recommendation: return domain traffic to the old writer while preserving expanded columns. Contract migrations wait until the rollback window closes; reconcile any new-only writes first.
Typed query access and concurrent pool usage can improve maintainability and remove an unnecessary application-wide lock.
Requires: Queries generated from the reviewed schema; representative null/time/transaction fixtures; a pool sized across all replicas.
Tradeoffs: Generated types do not prove isolation or business correctness; pool exhaustion and migrations still need operations.
Capture existing queue kind, JSON arguments, retry/schedule/dead-letter states and external-effect idempotency. Redis/Resque or Sidekiq payloads are not River payloads.
Recommendation: keep old workers consuming old queues. Route selected job kinds into River through versioned producers; transform outstanding states explicitly and retain one scheduler. River Ruby integration is a possible bridge, not automatic Active Job execution.
Recommendation: River PostgreSQL jobs with domain writes plus InsertTx in the same transaction, explicit queue concurrency and bounded retry policy. Keep Redis for any remaining broker/session/cache responsibility.
Recommendation: stop new River producers and reroute only unstarted work after reconciliation. Keep a compatible River consumer for already accepted jobs; a broker switch cannot undo sent messages or payments.
Atomic enqueue closes the gap between committing domain state and creating work.
Requires: Domain rows and River insertion use the same transaction/database; validated job-kind/argument mapping; replay-safe external effects.
Tradeoffs: Adds queue schema/maintenance to the database; retries can repeat effects; backlog migration and adapter compatibility are separate work.
Preserve response/error behavior, overload rules, deadlines and restart guarantees; establish separate budgets for HTTP and background jobs.
Recommendation: serve a fixed tenant/endpoint cohort from Go behind existing routing, with errgroup/context cancellation inside each operation and deployment-level readiness. Keep the old instance ready for contract-compatible rollback.
Recommendation: signal.NotifyContext, bounded admission/fan-out, Server.Shutdown with a fresh timeout context, tracked worker termination and pool closure after accepted work ends.
Recommendation: return routing to the old process and inspect committed outcomes and queued work before any replay. Preserve identical database/schema contracts for both versions.
Cooperative cancellation limits work that callers no longer need and makes planned shutdown observable.
Requires: Every called operation honors context; in-flight tasks are tracked; the platform shutdown grace period exceeds the configured drain budget.
Tradeoffs: Cancellation does not reverse a committed write or external effect; forced termination still loses memory-only work.
Preserve authentication, subscription identifiers, frame formats, ordering, reconnect cursors and cross-runtime fan-out. A WebSocket transport does not implement Action Cable automatically.
Recommendation: keep the existing broker and explicit application-protocol adapter while moving complete room/tenant cohorts, including reconnects, to Go. Publish/subscribe in both directions using captured protocol fixtures.
Recommendation: coder/websocket for transport plus bounded per-connection queues, tracked close handshakes and an application resynchronization path. Retain Redis Pub/Sub if ephemeral cross-process fan-out fits; add durable history separately where missed events matter.
Recommendation: route the cohort and reconnects back together. Keep the broker and old protocol alive; rebuild client state from durable records rather than pretending ephemeral events can be replayed.
Explicit connection ownership and queue limits bound slow-client resource use.
Requires: Capacity and disconnect policy are defined; clients can reconnect and reconstruct authoritative state; broker/protocol compatibility is tested.
Tradeoffs: Redis Pub/Sub is at-most-once and does not replay disconnected messages; replacing it with process-local channels removes cross-instance delivery.
Run these in the configured application. They are instructions, not recorded passes.
gofmt -l .
go test ./...
go test -race ./...
go vet ./...
govulncheck ./...
sqlc generate
goose -dir migrations status
go build ./cmd/serverOriginal source review: 2026-10-10. Core guidance rechecked: 2026-10-13. Check scope.