style
esc
  • Loading…

Start hereGo Style Guide template

Conventions for writing, structuring, testing and shipping Go 1.27 services, agents and CLIs that stay simple, explicit and easy to read.

Go 1.27golangci-lintslog · synctest

A ready-to-run invoice service with the guide's cmd/internal layout, a pgx and sqlc PostgreSQL store with goose migrations, a stdlib HTTP API with problem+json errors, slog logging, Prometheus RED metrics and pprof on an internal listener, graceful shutdown, the appendix golangci-lint and Taskfile configs, table, synctest, fuzz and integration tests, Docker, GoReleaser and CI.

  1. 1

    Download

    Pick a name and module path; the module, the binary (name + d) and the folders are renamed for you.

  2. 2

    Install

    Install Go 1.27, Task and Docker; every other tool runs through go tool from go.mod, nothing global.

  3. 3

    Run

    Run task lint and task test, then docker compose -f deploy/compose.yaml up --build to serve on :8080.

What you get

project/
├── .github/
│   ├── workflows/
│   │   ├── ci.yml
│   │   └── release.yml
│   └── dependabot.yml
├── api/
├── cmd/
│   └── projectd/
│       ├── main_test.go
│       └── main.go
├── deploy/
│   ├── compose.yaml
│   └── Dockerfile
├── docs/
│   └── adr/
│       └── 0001-record-scope.md
├── internal/
│   ├── config/
│   │   ├── config_test.go
│   │   └── config.go
│   ├── httpapi/
│   │   ├── invoices.go
│   │   ├── metrics_internal_test.go
│   │   ├── metrics_test.go
│   │   ├── metrics.go
│   │   ├── middleware.go
│   │   ├── respond.go
│   │   ├── server_test.go
│   │   └── server.go
│   ├── invoice/
│   │   ├── invoice_test.go
│   │   ├── invoice.go
│   │   ├── service_test.go
│   │   ├── service.go
│   │   ├── status_string.gen.go
│   │   ├── status.go
│   │   └── store.go
│   ├── platform/
│   │   ├── debug_test.go
│   │   ├── debug.go
│   │   ├── log.go
│   │   ├── serve_test.go
│   │   └── serve.go
│   ├── postgres/
│   │   ├── db/
│   │   │   ├── db.gen.go
│   │   │   ├── invoice.sql.gen.go
│   │   │   └── models.gen.go
│   │   ├── queries/
│   │   │   └── invoice.sql
│   │   ├── invoice_store_test.go
│   │   ├── invoice_store.go
│   │   └── postgres.go
│   └── version/
│       └── version.go
├── migrations/
│   └── 00001_create_invoices.sql
├── scripts/
├── testdata/
├── .dockerignore
├── .gitignore
├── .golangci.yml
├── .goreleaser.yaml
├── go.mod
├── go.sum
├── README.md
├── sqlc.yaml
└── Taskfile.yml