Project Layout & Clean Architecture in Go
- Lay out a Go service module with
cmd/andinternal/, organised by domain rather than technical layer, and justify (or reject)pkg/. - Implement ports-and-adapters for a payments capture flow: domain, use case, PostgreSQL and PSP adapters, HTTP edge.
- Handle transactions across repositories without leaking
pgx.Txinto business logic. - Wire dependencies by hand in
main, compare withwire/fx, and load validated configuration that never logs secrets. - Argue monorepo vs polyrepo for a Go organisation.
TL;DR
- Start flat; grow into
cmd/<binary>/main.go+internal/<domain>/....internal/is enforced by the compiler;pkg/has no special meaning — skip it in services. - Package by domain (
internal/payment,internal/ledger), not by layer (models/,services/,controllers/). - Hexagonal in Go is cheap: domain (pure types and rules) ← app (use cases + port interfaces it owns) ← adapters (postgres, psp, http, kafka). Dependencies point inward;
mainwires everything. - Expose transactions as a port (
WithinTx(ctx, func(ctx, Stores) error)), never as*sql.Txin use-case signatures. Never hold a DB transaction across a network call to a PSP. - Dependency injection by hand — constructors with explicit parameters, composition in
main— is the Go default.wire(codegen) orfx(runtime) only when wiring is genuinely large. - Config: one typed struct, parsed and validated at startup, injected; secrets from a secret store; implement
slog.LogValuerso secrets can't be logged.
Why it matters
A bank or a large e-commerce company runs dozens to hundreds of Go services across many teams. Structure is how you get:
- Replaceable integrations — moving from one card processor to another, or adding a domestic switch, touches one adapter package, not the capture logic.
- Testable money logic — state transitions and fee rules tested in milliseconds with fakes, independent of PostgreSQL and HTTP.
- Auditability — reviewers and auditors can find "where is the capture rule?" in one place;
internal/prevents other teams from depending on your database adapter. - Onboarding and ownership — consistent layouts across services, clear CODEOWNERS boundaries.
Over-structuring is equally real: a 400-line CRUD service with six layers, twenty interfaces and a DI framework is slower to change than a flat one. The skill is matching structure to complexity.
Core concepts
Module layout
Go's official guidance ("Organizing a Go module" on go.dev) is short: start with a single package, add cmd/ when you have several binaries, and use internal/ for code not meant for import. The popular golang-standards/project-layout repository is not an official standard — Go team members have said so publicly — so treat it as one opinion.
payments/
├── go.mod module gitlab.bank.internal/payments
├── cmd/
│ ├── api/main.go HTTP + gRPC server
│ ├── worker/main.go outbox relay, settlement consumer
│ └── migrate/main.go schema migrations
├── internal/
│ ├── payment/
│ │ ├── domain/ entities, value objects, domain errors; no infra imports
│ │ ├── app/ use cases and the port interfaces they own
│ │ └── adapter/
│ │ ├── postgres/ repositories, TxRunner (pgx)
│ │ ├── psp/ card-processor client
│ │ ├── httpapi/ handlers, DTOs, error mapping
│ │ └── kafka/ event publisher
│ ├── ledger/ another bounded context, same shape
│ └── platform/ config, logging, telemetry, health
├── api/ openapi.yaml, .proto files
├── migrations/ versioned SQL
└── deploy/ Dockerfile, Helm or Kustomize
Rules of thumb:
cmd/<name>/main.gois thin: load config, build dependencies, run, handle signals. No business logic.internal/for everything else in a service. Code undera/b/internal/can only be imported by code rooted ata/b/.pkg/: in a service, nothing should be imported by other modules, sopkg/adds a path segment and nothing else. In a library, put the public API at the module root. Some organisations usepkg/by convention for shared code — consistency within the org beats purity.- Package names describe what they provide:
postgres,psp,httpapi— notutils,common,helpers,models. - Bounded contexts (
payment,ledger) map to top-level packages underinternal/; they talk through use-case APIs or events, not by importing each other's adapters. See Domain-Driven Design.
Hexagonal architecture in Go
- Domain imports only the standard library (and maybe a money/decimal package). No
pgx, no protobuf, nonet/http. - App (use cases) defines the interfaces it needs — repositories, gateways, outbox, transaction runner — following "the consumer defines the interface" from Interfaces & Composition.
- Adapters import
appanddomainand implement the ports. They translate infrastructure errors into domain errors. mainis the composition root.
The theory is in Clean & Hexagonal Architecture; below is what it looks like in Go.
The domain: state transitions as methods
// internal/payment/domain/payment.go
package domain
import (
"errors"
"fmt"
)
type Status string
const (
StatusPending Status = "PENDING"
StatusAuthorized Status = "AUTHORIZED"
StatusCaptured Status = "CAPTURED"
StatusFailed Status = "FAILED"
)
var (
ErrNotFound = errors.New("payment: not found")
ErrInvalidTransition = errors.New("payment: invalid state transition")
ErrConcurrentUpdate = errors.New("payment: concurrent update")
)
type Payment struct {
ID string
OrderID string
Amount int64 // minor units
Currency string
Status Status
AuthCode string
Version int64 // optimistic locking
}
func (p *Payment) MarkAuthorized(authCode string) error {
if p.Status != StatusPending {
return fmt.Errorf("%w: %s to %s", ErrInvalidTransition, p.Status, StatusAuthorized)
}
p.Status, p.AuthCode = StatusAuthorized, authCode
return nil
}
func (p *Payment) MarkCaptured() error {
if p.Status != StatusAuthorized {
return fmt.Errorf("%w: %s to %s", ErrInvalidTransition, p.Status, StatusCaptured)
}
p.Status = StatusCaptured
return nil
}
// PaymentCaptured is the integration event written to the outbox.
type PaymentCaptured struct {
PaymentID string
OrderID string
Amount int64
Currency string
}
The state machine lives with the data, so no handler or adapter can move a payment from PENDING straight to CAPTURED (see Order Management & State Machines).
The use case and its ports
// internal/payment/app/capture.go
package app
import (
"context"
"fmt"
"gitlab.bank.internal/payments/internal/payment/domain"
)
// Ports owned by the use case.
type PaymentRepository interface {
Get(ctx context.Context, id string) (*domain.Payment, error)
// Update must fail with domain.ErrConcurrentUpdate if p.Version is stale.
Update(ctx context.Context, p *domain.Payment) error
}
type Outbox interface {
Enqueue(ctx context.Context, evt domain.PaymentCaptured) error
}
type Gateway interface {
// Capture must be idempotent per paymentID at the provider.
Capture(ctx context.Context, paymentID string, amount int64, currency string) error
}
// Stores are repositories bound to one transaction.
type Stores struct {
Payments PaymentRepository
Outbox Outbox
}
type TxRunner interface {
WithinTx(ctx context.Context, fn func(ctx context.Context, s Stores) error) error
}
type CaptureService struct {
payments PaymentRepository // non-transactional reads
tx TxRunner
psp Gateway
}
func NewCaptureService(payments PaymentRepository, tx TxRunner, psp Gateway) *CaptureService {
return &CaptureService{payments: payments, tx: tx, psp: psp}
}
func (s *CaptureService) Capture(ctx context.Context, paymentID string) error {
p, err := s.payments.Get(ctx, paymentID)
if err != nil {
return fmt.Errorf("load payment %s: %w", paymentID, err)
}
if p.Status != domain.StatusAuthorized {
return fmt.Errorf("capture %s: %w", paymentID, domain.ErrInvalidTransition)
}
// Network call OUTSIDE any DB transaction. Idempotent per payment ID,
// so a crash before the commit below is safe to retry.
if err := s.psp.Capture(ctx, p.ID, p.Amount, p.Currency); err != nil {
return fmt.Errorf("capture %s at psp: %w", paymentID, err)
}
// State change and event commit atomically (transactional outbox).
return s.tx.WithinTx(ctx, func(ctx context.Context, st Stores) error {
if err := p.MarkCaptured(); err != nil {
return err
}
if err := st.Payments.Update(ctx, p); err != nil {
return fmt.Errorf("persist capture %s: %w", paymentID, err)
}
return st.Outbox.Enqueue(ctx, domain.PaymentCaptured{
PaymentID: p.ID, OrderID: p.OrderID, Amount: p.Amount, Currency: p.Currency,
})
})
}
Why this shape:
- No
pgx.Txin the use case. The transaction is a port; tests pass a fakeTxRunnerthat just callsfnwith in-memory stores. - No DB transaction across the PSP call — holding row locks for a 2–30 s network call is a classic way to exhaust the connection pool during a sales peak.
- Outbox in the same transaction as the state change, so "captured" and "event published" can't diverge (see Transactional Outbox & CDC).
- Optimistic locking (
Version) catches a concurrent refund/capture; the adapter maps a stale update toErrConcurrentUpdate. - A crash between PSP capture and commit leaves the payment
AUTHORIZEDthough the money was captured — a reconciliation job (or retryingCapture, which is idempotent at the PSP) repairs it. Name that failure mode in interviews.
The PostgreSQL adapter
// internal/payment/adapter/postgres/payments.go
package postgres
import (
"context"
"errors"
"fmt"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/pgxpool"
"gitlab.bank.internal/payments/internal/payment/app"
"gitlab.bank.internal/payments/internal/payment/domain"
)
// DBTX is satisfied by both *pgxpool.Pool and pgx.Tx.
type DBTX interface {
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
type PaymentRepo struct{ db DBTX }
func NewPaymentRepo(db DBTX) *PaymentRepo { return &PaymentRepo{db: db} }
func (r *PaymentRepo) Get(ctx context.Context, id string) (*domain.Payment, error) {
var p domain.Payment
err := r.db.QueryRow(ctx,
`SELECT id, order_id, amount_minor, currency, status, auth_code, version
FROM payments WHERE id = $1`, id).
Scan(&p.ID, &p.OrderID, &p.Amount, &p.Currency, &p.Status, &p.AuthCode, &p.Version)
if errors.Is(err, pgx.ErrNoRows) {
return nil, domain.ErrNotFound
}
if err != nil {
return nil, fmt.Errorf("select payment %s: %w", id, err)
}
return &p, nil
}
func (r *PaymentRepo) Update(ctx context.Context, p *domain.Payment) error {
tag, err := r.db.Exec(ctx,
`UPDATE payments SET status = $1, auth_code = $2, version = version + 1
WHERE id = $3 AND version = $4`,
p.Status, p.AuthCode, p.ID, p.Version)
if err != nil {
return fmt.Errorf("update payment %s: %w", p.ID, err)
}
if tag.RowsAffected() == 0 {
return domain.ErrConcurrentUpdate
}
p.Version++
return nil
}
type OutboxRepo struct{ db DBTX }
func (o *OutboxRepo) Enqueue(ctx context.Context, evt domain.PaymentCaptured) error {
_, err := o.db.Exec(ctx,
`INSERT INTO outbox (aggregate_id, event_type, payload)
VALUES ($1, 'payment.captured', json_build_object(
'payment_id', $1::text, 'order_id', $2::text,
'amount', $3::bigint, 'currency', $4::text))`,
evt.PaymentID, evt.OrderID, evt.Amount, evt.Currency)
return err
}
// TxRunner implements app.TxRunner with pgx.
type TxRunner struct{ pool *pgxpool.Pool }
func NewTxRunner(pool *pgxpool.Pool) *TxRunner { return &TxRunner{pool: pool} }
func (t *TxRunner) WithinTx(ctx context.Context, fn func(context.Context, app.Stores) error) error {
// BeginFunc commits if fn returns nil and rolls back otherwise (including panics).
return pgx.BeginFunc(ctx, t.pool, func(tx pgx.Tx) error {
return fn(ctx, app.Stores{
Payments: &PaymentRepo{db: tx},
Outbox: &OutboxRepo{db: tx},
})
})
}
The DBTX interface (the same trick sqlc generates) lets one repository type work both inside and outside a transaction.
Composition root: dependency injection by hand
// cmd/api/main.go
package main
import (
"context"
"errors"
"log/slog"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/jackc/pgx/v5/pgxpool"
"gitlab.bank.internal/payments/internal/payment/adapter/httpapi"
"gitlab.bank.internal/payments/internal/payment/adapter/postgres"
"gitlab.bank.internal/payments/internal/payment/adapter/psp"
"gitlab.bank.internal/payments/internal/payment/app"
"gitlab.bank.internal/payments/internal/platform/config"
)
func main() {
log := slog.New(slog.NewJSONHandler(os.Stdout, nil))
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := run(ctx, log); err != nil {
log.Error("exit", "err", err)
os.Exit(1)
}
}
func run(ctx context.Context, log *slog.Logger) error {
cfg, err := config.Load()
if err != nil {
return err // fail fast: misconfiguration never reaches traffic
}
log.Info("starting", "config", cfg) // Config implements slog.LogValuer: no secrets
pool, err := pgxpool.New(ctx, cfg.DatabaseURL)
if err != nil {
return err
}
defer pool.Close()
gateway := psp.NewClient(cfg.PSPBaseURL, cfg.PSPAPIKey, &http.Client{Timeout: cfg.PSPTimeout})
capture := app.NewCaptureService(postgres.NewPaymentRepo(pool), postgres.NewTxRunner(pool), gateway)
srv := &http.Server{
Addr: cfg.HTTPAddr,
Handler: httpapi.NewRouter(capture, log),
ReadHeaderTimeout: 5 * time.Second,
}
go func() {
<-ctx.Done()
sctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
_ = srv.Shutdown(sctx)
}()
if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
return err
}
return nil
}
Everything a component needs is a constructor parameter, so the dependency graph is readable top to bottom and the compiler checks it. Optional settings use functional options (psp.NewClient(url, key, hc, psp.WithRetries(3))) rather than giant parameter lists.
| Approach | How | Strengths | Weaknesses |
|---|---|---|---|
| By hand | Constructors + main | Explicit, compile-checked, zero magic | main grows with the graph |
google/wire | Code generation from provider sets | Compile-time, generated code is plain Go | Extra tool, generated file to maintain |
uber-go/fx | Runtime reflection container with lifecycle hooks | Modules, lifecycle (start/stop) built in | Errors at startup not compile time; harder to trace |
Most services never outgrow the by-hand approach; split run into newRepositories, newServices, newServers helpers before reaching for a framework.
Configuration
// internal/platform/config/config.go
package config
import (
"errors"
"fmt"
"log/slog"
"os"
"time"
)
type Config struct {
HTTPAddr string
DatabaseURL string // contains credentials: never logged
PSPBaseURL string
PSPAPIKey string // from the secret store via env or mounted file
PSPTimeout time.Duration
}
func Load() (Config, error) {
cfg := Config{
HTTPAddr: getenv("HTTP_ADDR", ":8080"),
DatabaseURL: os.Getenv("DATABASE_URL"),
PSPBaseURL: os.Getenv("PSP_BASE_URL"),
PSPAPIKey: os.Getenv("PSP_API_KEY"),
}
var errs []error
if cfg.DatabaseURL == "" {
errs = append(errs, errors.New("DATABASE_URL is required"))
}
if cfg.PSPBaseURL == "" || cfg.PSPAPIKey == "" {
errs = append(errs, errors.New("PSP_BASE_URL and PSP_API_KEY are required"))
}
d, err := time.ParseDuration(getenv("PSP_TIMEOUT", "5s"))
if err != nil || d <= 0 || d > 30*time.Second {
errs = append(errs, fmt.Errorf("PSP_TIMEOUT must be in (0, 30s]: %q", os.Getenv("PSP_TIMEOUT")))
}
cfg.PSPTimeout = d
return cfg, errors.Join(errs...) // report every problem at once
}
// LogValue keeps secrets out of logs even if someone logs the whole struct.
func (c Config) LogValue() slog.Value {
return slog.GroupValue(
slog.String("http_addr", c.HTTPAddr),
slog.String("psp_base_url", c.PSPBaseURL),
slog.Duration("psp_timeout", c.PSPTimeout),
)
}
func getenv(key, def string) string {
if v, ok := os.LookupEnv(key); ok {
return v
}
return def
}
- Read configuration once, in
main, and inject it.os.Getenvscattered through packages makes behaviour untestable and undiscoverable. - Validate ranges, not just presence. A
PSP_TIMEOUTof5mis a valid duration and an outage waiting to happen. - Libraries like
caarlos0/envorkelseyhightower/envconfigreduce boilerplate with struct tags;spf13/viperadds files and remote sources at the cost of a heavier dependency. - Secrets come from Vault/KMS/Kubernetes secrets (mounted files are preferable to env vars, which leak into crash dumps and
/proc). Never commit them; rotate without redeploying where possible. See Security for Architects.
Monorepo vs polyrepo
| Monorepo (one or few modules) | Polyrepo (repo per service/lib) | |
|---|---|---|
| Shared code changes | One atomic commit across services | Version, release, bump in each consumer |
| Dependency versions | One go.mod (single module) keeps everything consistent | Each service on its own versions; MVS resolves diamonds per service |
| Build/test | Need affected-target detection (Bazel, or scripts on go list -deps) | Simple per-repo CI |
| Ownership | CODEOWNERS per directory | Repo permissions per team |
| Coupling risk | Easy to import across contexts — enforce with internal/ and linters | Coupling via shared libs and API contracts |
| Go specifics | Multi-module monorepos need go.work locally and tagged sub-module versions | Private module proxy (GOPRIVATE, Athens/Artifactory) essential |
Common middle ground in banks: a polyrepo of services plus a small number of well-versioned internal libraries (logging, telemetry, auth middleware), with a platform team owning those libraries. E-commerce companies with strong build tooling often run monorepos. Either way, avoid a "common" library that every service depends on and that changes weekly.
Trade-offs
| Option | Strengths | Weaknesses | Choose when |
|---|---|---|---|
| Flat single package | Fastest to write and read | Doesn't scale past a few thousand lines | Small tools, prototypes, tiny services |
| Package by domain + hexagonal | Testable core, swappable adapters, clear ownership | More packages and interfaces | Money flows, multiple integrations, long-lived services |
| Package by layer | Familiar from MVC frameworks | Every feature touches every package; cycles | Rarely in Go |
| Full DDD tactical patterns | Rich domain model | Ceremony for simple CRUD | Complex invariants (ledgers, pricing, orders) |
internal/ everywhere | Compiler-enforced boundaries | Sharing requires deliberate moves | Services (default) |
pkg/ | Signals "importable" | Meaningless to the toolchain | Only if your org standardises on it |
| DI by hand | Explicit, compile-checked | Verbose main | Default |
wire / fx | Less wiring code, lifecycle hooks (fx) | Tooling or runtime magic | Very large graphs, many shared modules |
In practice
- Enforce boundaries in CI:
depguardorgo-arch-lint-style rules ("domainmust not importadapter", "paymentmust not importledger/adapter"). - One
mainper deployable;cmd/workerandcmd/apishare the sameinternal/packages but get separate images and scaling. - Migrations live with the service and run as a separate step or job (
cmd/migrate), not on app startup with many replicas racing. See Zero-Downtime Schema Migrations. - Generated code (sqlc, protobuf) goes in its own package (
internal/payment/adapter/postgres/db,gen/) and is never edited by hand; adapters wrap it so generated types don't leak into the domain. - Keep handlers thin: decode → validate → call use case → map result/error. If a handler has an
ifabout payment status, logic has leaked out of the domain.
Common pitfalls
- Cargo-culting
golang-standards/project-layout—pkg/,api/,web/,build/folders for a 2-file service. - Interfaces defined in adapter packages "for mocking" — the core then imports the adapter package; dependency inversion lost.
- Domain types with
db:/json:tags andpgtypefields — the database schema dictates the domain. Map at the adapter. *sql.Tx/pgx.Txin use-case signatures — business logic coupled to a driver; can't test without a DB.- DB transaction held across HTTP/PSP calls — pool exhaustion and lock contention under load.
- Package
util/common— grows into a dependency magnet that causes import cycles. - Global singletons and
init()wiring — hidden dependencies; tests interfere with each other. - Reading env vars deep in the code — undocumented configuration; impossible to test variants.
- Over-abstracting CRUD — six layers for "save a merchant's address".
Interview angle
Prompts: "How do you structure a Go microservice?", "Walk me through clean/hexagonal architecture in Go for a payment flow", "How do you handle transactions across repositories?", "Do you use a DI framework?", "What's in internal/ vs pkg/?", "Monorepo or polyrepo?"
A strong answer sketches the tree, explains internal/ enforcement and why pkg/ is optional, packages by domain, shows ports owned by the use case, the WithinTx port, the outbox in the same transaction, the PSP call outside it with idempotency, and wiring in main. Mention the crash-between-capture-and-commit failure mode and how reconciliation repairs it. For DI, say "by hand by default" and when fx's lifecycle hooks would justify it.
Follow-ups: "How do bounded contexts communicate?" (use-case API in-process, or events), "Where do DTOs live?" (adapter package), "How do you stop teams importing each other's internals?" (internal/, lint rules, CODEOWNERS).
Red flags: one interface per struct, framework-first answers, domain entities that are ORM models, no thought about transaction boundaries.
Self-check
1. What does internal/ enforce that pkg/ doesn't, and when would you still use pkg/?
The go tool rejects imports of .../internal/... from outside the tree rooted at its parent, so internals can't become someone else's dependency. pkg/ has no meaning to the toolchain; use it only if your organisation standardises on it for shared, importable code. In a service, everything belongs in internal/.
2. Why does CaptureService define PaymentRepository and Gateway instead of importing them from the adapter packages?
Dependency inversion: the core declares what it needs, adapters depend on the core and implement it. The core then compiles and tests without PostgreSQL or the PSP SDK, and swapping the card processor only touches an adapter. Importing adapter-defined interfaces would point the dependency arrow outward.
3. Why is the PSP capture call made outside the database transaction, and what failure mode does that create?
A transaction held during a slow network call keeps row locks and a pooled connection busy for seconds, which collapses throughput under load. The trade-off: if the process crashes after the PSP captured but before the commit, the DB still says AUTHORIZED. Because capture is idempotent per payment ID, a retry or a reconciliation job against PSP reports repairs it.
4. How does the DBTX interface let one repository work inside and outside a transaction?
Both *pgxpool.Pool and pgx.Tx have Exec/QueryRow with the same signatures, so they satisfy DBTX. The TxRunner constructs repositories with the pgx.Tx; normal reads construct them with the pool. Business code never sees which one it has.
5. A teammate wants uber-go/fx for a service with 12 components. What do you say?
By-hand wiring for 12 components is a ~40-line run function that the compiler checks and anyone can read; fx moves errors to startup time and makes the graph implicit. Recommend by-hand, perhaps split into helper constructors; revisit fx if many services need shared lifecycle-managed modules.
6. Scenario: your bank has 60 Go services in separate repos, each copying logging and auth middleware with drift. Propose a structure.
Extract a small set of internal libraries (logging/telemetry setup, auth middleware, error mapping) into versioned modules owned by a platform team, served through a private module proxy with GOPRIVATE. Keep them small and stable with semantic versioning; automate upgrades (Renovate/Dependabot). Consider a monorepo only if the organisation is ready for affected-target CI tooling.
Exercise
Build the capture slice end to end:
- Create the layout above with
domain,app,adapter/postgres,adapter/psp(anhttptestfake PSP),adapter/httpapiandcmd/api. - Implement
CaptureServicewith fakes for every port and unit-test: happy path, invalid state, PSP failure (no state change), concurrent update (ErrConcurrentUpdate). - Implement the PostgreSQL adapter with optimistic locking and an outbox table; test it with testcontainers.
- Add a
depguard(or equivalent) rule that fails CI ifdomainimports anything outside the standard library. - Write
cmd/workerthat relays outbox rows to a fake publisher, sharing the sameinternal/packages.
Done when: go test ./internal/payment/app/... runs in under a second without Docker, the integration suite proves optimistic locking, and main is the only file that imports every adapter. Compare with Hands-on Go Labs.
Further reading
- Go documentation: "Organizing a Go module" (go.dev/doc/modules/layout).
- Go blog: "Package names" (Sameer Ajmani).
- Robert C. Martin, Clean Architecture — the dependency rule.
- Alistair Cockburn, "Hexagonal Architecture" (Ports and Adapters) article.
- Eric Evans, Domain-Driven Design — bounded contexts and aggregates.
- Mat Ryer, "How I write HTTP services in Go after 13 years" (Grafana Labs blog).
- Peter Bourgon, "Go best practices, six years in" — structure and configuration advice.
- Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them — project organisation and utility packages.
Related
- Clean & Hexagonal Architecture — the architecture-level theory.
- Domain-Driven Design — bounded contexts that map to
internal/<domain>. - Transactional Outbox & CDC — why the event is written in the same transaction.
- Building Production Services — the HTTP, gRPC and observability adapters in detail.
- SOLID in Go — dependency inversion and interface segregation in practice.
- Microservices Patterns — when a bounded context becomes its own service.
Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).