The App
Getting started
Bogie is a CLI, not a library. It renders a new Go service onto disk and then gets out of the way: the app it generates never imports Bogie itself, and the only bogie-go library it uses is credentials, so deleting the tool tomorrow does not touch the app.
Install
go install github.com/bogie-go/bogie@latest
go install prints nothing when it works. If the next command fails with one of these, Go put the binary in a directory your shell does not search:
zsh:1: command not found: bogie
bash: bogie: command not found
command not found: bogie means $(go env GOPATH)/bin is not on your PATH. Add export PATH="$PATH:$(go env GOPATH)/bin" to your shell profile, open a new terminal, and run bogie version.
@latest is the newest tagged release, v1.0.1 as of this build, and bogie version prints it. You need Go 1.26 or newer (the tool itself builds with 1.25, but the generated app pins an sqlc that needs 1.26) and Docker with Compose v2, which runs the app's Postgres on port 5440, clear of a Postgres already running on 5432. Already run Postgres yourself? See Your own Postgres. For main as it stands, go install github.com/bogie-go/bogie@main; from a clone, go install ..
Generate a service
bogie new blog
This writes an API-only, Postgres-only Go service, runs go mod tidy, and makes the development credentials file. Three flags change what it writes:
--module=PATHsets the Go module path, if it should not be the app's name.--id=uuidmakes every primary key a uuid instead of the defaultbigint. It is chosen once for the whole app and recorded inbogie.toml. See Id schemes.--jobsadds River on the same Postgres: a worker role,app/jobs, andg job. See Background jobs.
It prints one line per file it writes, then the next steps (the list of create lines is trimmed here):
create blog/AGENTS.md
create blog/CLAUDE.md
create blog/Dockerfile
...
create blog/config/master.key
create blog/config/credentials.yml.enc
run go mod tidy
Next:
cd blog
make up # postgres on :5440, via docker compose
bogie db:prepare # create, migrate, seed
bogie server
curl localhost:8080/healthz
Run bogie new again in a directory that already has the app and it lists each file as identical or conflict, then ends with a line saying the files that differ are only overwritten with --force:
conflict blog/AGENTS.md
identical blog/CLAUDE.md
...
bogie: new: 18 files differ; rerun with --force to overwrite them
rerun with --force to overwrite them: only do that if you want your edits to those files replaced.
The generated tree
Laid out by role, on purpose, so you know where to look:
main.go dispatches: serve | migrate | db | routes
cli.go the migrate and db subcommands
bogie.toml the Bogie version and the choices (id scheme, jobs) behind this app
app/
application.go wiring: migrate at boot, config, connections, controllers
controllers/
application.go root Server, one NAMED field per controller
routes.go the whole routing table
public.go the no-route chain: a file in public/, else 404.html
welcome.go the development page at /; gone once a route claims /
middlewares/ request id · logging · recover
services/database/ db create and drop, through the maintenance database
services/migrate/ goose over the embedded migrations
views/ wire contracts; model structs never double as wire structs
models/ THE MODELS: types and their rules; imports nothing third-party
config/ credentials file + env → validated struct, no globals
deploy.yml Kamal 2, staging; deploy.production.yml overlays it
.kamal/secrets what Kamal substitutes: the master key and the registry password
Dockerfile one image, every role; keys never enter it
db/
db.go go:embed of migrate/*.sql
adapter/ the Store: validation and row conversion between app/models and sqlc
sqlc/ what sqlc generates (make sqlc); never edited
sqlc.yaml sqlc's settings
migrate/ goose SQL, timestamped in UTC; g model writes the first
queries/ named SQL, one file per table; sqlc compiles it
seeds/ plain Go, one function per file; db seed runs them all, every time
public/ 404.html · 500.html · images/, go:embedded
lib/logger/
test/ testdb · testapp · factories · requests: what tests share
bin/ci the whole pipeline, run locally
There is no table yet: Models and migrations writes the first.
Bring up the database and serve
cd blog
make up
bogie db:prepare
bogie server
make up starts Postgres under Docker Compose on port 5440 and waits until it answers. bogie db:prepare creates the database if it does not exist, migrates it and seeds it. bogie server (or bogie s) runs the HTTP server; it migrates at boot, the way a deployed container does. In development it also runs under Air, so saving a file rebuilds and restarts it; since migrations are embedded in the binary and applied at boot, a new one is picked up on the next reload too. bogie worker reloads the same way, to its own binary, so the two run side by side in two terminals. Production runs the compiled binary, untouched; make server and make worker are the plain, one-boot equivalents.
What each command prints. make up:
docker compose up -d --wait
Network blog-service_default Creating
Network blog-service_default Created
Volume blog-service_pgdata Creating
Volume blog-service_pgdata Created
Container blog-db Creating
Container blog-db Created
Container blog-db Starting
Container blog-db Started
Container blog-db Waiting
Container blog-db Healthy
ready: postgres on :5440
Since v0.7.0 the ready line reports the published port (docker compose port db 5432), not a hardcoded :5440. The default is still 5440; if you have moved the Compose port, the line follows. The app still dials whatever config.go and the credentials (or DATABASE_URL) say.
Running bogie db:prepare on a database that is already set up prints:
time=2026-11-05T08:56:23.386+07:00 level=INFO msg="database already exists" service=blog database=blog_development
time=2026-11-05T08:56:23.386+07:00 level=INFO msg="schema: nothing to apply" service=blog dir=migrate
bogie server prints the app's settings and then http listening (Air's banner and the route list are trimmed):
blog: env=development settings="config/credentials.yml.enc" key="config/master.key"
blog: addr=:8080 log_level=debug shutdown_grace=10s database=postgres://postgres:xxxxx@localhost:5440/blog_development?sslmode=disable migrate_at_boot=true
time=2026-11-05T08:56:25.497+07:00 level=INFO msg="schema: nothing to apply" service=blog dir=migrate
...
time=2026-11-05T08:56:25.513+07:00 level=INFO msg="http listening" service=blog addr=:8080 env=development
In another terminal, curl -i localhost:8080/healthz answers:
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
X-Request-Id: c74129d0-121d-4660-81f4-415221ddf261
Date: Thu, 05 Nov 2026 01:56:35 GMT
Content-Length: 2
ok
connection refused is what bogie db:prepare and bogie server print when Postgres is not running. Bogie adds its own hint under the error:
blog: database: create blog_development: failed to connect to `user=postgres database=postgres`:
[::1]:5440 (localhost): dial error: dial tcp [::1]:5440: connect: connection refused
127.0.0.1:5440 (localhost): dial error: dial tcp 127.0.0.1:5440: connect: connection refused
Nothing is listening on localhost:5440, which is the bundled Postgres.
Start it, then create the database:
make up
bogie db:prepare
Run make up, then bogie db:prepare, and try again.
listen tcp :8080: bind: address already in use means something else already holds port 8080, often another bogie server in a second terminal. Stop it and start again:
blog: listen tcp :8080: bind: address already in use
The reverse, curl: (7) Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server, means nothing is listening: start bogie server first.
Visit / in development for a welcome page with the environment, the listen address and the Go version, and GET /healthz for the plain text a load balancer checks. The welcome page disappears the moment any controller claims /, or you add a public/index.html; in every other environment / answers with public/404.html until something is there. bogie routes lists what is actually mounted. See Static files and error pages.
Run the tests
BLOG_ENV=test bogie db:prepare # once: the prefix is the app name, upper-cased
bogie test
The test database prepare prints:
time=2026-11-05T08:57:31.328+07:00 level=INFO msg="database created" service=blog database=blog_test
time=2026-11-05T08:57:31.328+07:00 level=INFO msg="schema: nothing to apply" service=blog dir=migrate
A passing bogie test ends with one line per package (trimmed):
ok blog/app/controllers 1.997s coverage: 66.7% of statements
ok blog/app/middlewares (cached) coverage: 0.0% of statements
ok blog/app/models (cached) coverage: [no statements]
...
ok blog/test/requests 1.505s coverage: [no statements]
Without the test database, each failing package prints these two lines (the rest of the output is trimmed):
127.0.0.1:5440 (localhost): server error: FATAL: database "blog_test" does not exist (SQLSTATE 3D000)
Is the database up, and the test database created? Run: make up && BLOG_ENV=test bogie db:prepare (bin/ci does both)
database "blog_test" does not exist: run BLOG_ENV=test bogie db:prepare once, as above.
Tests use their own database, blog_test, so your development data survives a test run. bogie db:prepare on its own prepares only the development database, and bogie test without the test database fails with a hint to run the line above. bin/ci rebuilds the test database itself. See Testing and CI.
Check the app is sound
bin/ci
The whole pipeline, run on the machine you already have: it rebuilds the test database from the migrations, rolls them down and back up, checks that sqlc's generated code in db/sqlc is current (sqlc diff), runs gofmt, vet, golangci-lint, the build, and the test suite. A green run on a clean tree signs the commit off with gh signoff, if that extension is installed.
A green run prints a == header and an ok line for each step, and ends like this (the middle is trimmed):
== Setup: modules
all modules verified
ok Setup: modules (10s)
== Setup: database
...
ok Setup: database (2s)
== Schema: down and up
...
ok Schema: down and up (0s)
== Schema: sqlc current
ok Schema: sqlc current (1s)
== Style: gofmt
ok Style: gofmt (0s)
== Style: go vet
ok Style: go vet (0s)
== Style: golangci-lint
0 issues.
ok Style: golangci-lint (6s)
== Build
ok Build (1s)
== Tests
...
ok Tests (40s)
== Worker: boots and drains
...
ok Worker: boots and drains (6s)
All systems go in 66s. Ready for merge and deploy.
The last step needs a pushed branch. When the branch has not been pushed it fails with cannot verify the current branch is pushed after the checks have passed:
== Signoff
Error: cannot verify the current branch is pushed (@{push} does not resolve; check push.default and branch tracking; -f to override)
FAIL Signoff (1s)
bin/ci needs golangci-lint v2, which Go does not bring with it; without it the lint step fails with the install line, and the run ends with CI failed in 20s. Do not merge or deploy.:
== Style: golangci-lint
golangci-lint is not installed. Install it with:
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
FAIL Style: golangci-lint (0s)
The install line:
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
bogie doctor is worth running any time the app feels off: it checks every marker the generators write is intact exactly once, that the pinned tools (goose, sqlc, credentials and Air) are still in go.mod, that the layout files generators depend on exist, and that every controller is both constructed and mounted. See Testing and CI for what each step of bin/ci does. A healthy app prints one ok line per check (trimmed):
ok bogie.toml
ok marker bogie:controllers in app/controllers/application.go
...
ok tool air
ok db/sqlc.yaml
...
ok config/master.key
All checks passed.
Your first resource
That app has no table yet. A scaffold writes a whole resource and registers it: the migration, the queries, the model, the store, the views, a controller and its tests.
bogie g scaffold product name:string price_cents:integer
It prints one line per file it wrote or edited (the migration's timestamp will be yours):
create db/migrate/20261031072511_create_products.sql
create db/queries/products.sql
create app/models/product.go
create app/models/product_test.go
create db/adapter/products.go
create db/adapter/products_test.go
create test/factories/products.go
create app/views/products.go
create app/controllers/products_controller.go
create app/controllers/products_controller_test.go
insert app/controllers/application.go: Products *ProductsController
insert app/application.go: server.Products = controllers.NewProductsController(store, log)
insert app/controllers/routes.go: s.Products.SetupRoutes(&r.RouterGroup)
run sqlc generate
Apply the migration. bogie server would do it at boot too.
bogie db:migrate
time=2026-10-31T14:25:12.345+07:00 level=INFO msg="schema applied" service=blog from=0 to=20261031072511
The scaffolded Validate in app/models/product.go accepts everything until you give it rules. Make a name required (and add "fmt" to the imports):
func (p Product) Validate() error {
if p.Name == "" {
return fmt.Errorf("%w: name is required", ErrInvalid)
}
return nil
}
Start the server if it is not running (bogie server reloads when you save a file), then call it. A blank name is refused with a 422, a good one is created, and the list shows it:
$ curl -i -X POST localhost:8080/products \
-H "Content-Type: application/json" -d '{"name":""}'
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json; charset=utf-8
X-Request-Id: 0ce1b3a8-9270-47e1-a70c-63ce82ba808c
Date: Sat, 31 Oct 2026 07:25:46 GMT
Content-Length: 54
{"status":"error","error":"invalid: name is required"}
$ curl -i -X POST localhost:8080/products \
-H "Content-Type: application/json" -d '{"name":"Blue mug","price_cents":1250}'
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
X-Request-Id: 19772870-4255-42bd-aace-4787be857598
Date: Sat, 31 Oct 2026 07:25:46 GMT
Content-Length: 141
{"id":1,"name":"Blue mug","price_cents":1250,"created_at":"2026-10-31T14:25:46.054672+07:00","updated_at":"2026-10-31T14:25:46.054672+07:00"}
$ curl localhost:8080/products
{"products":[{"id":1,"name":"Blue mug","price_cents":1250,"created_at":"2026-10-31T14:25:46.054672+07:00","updated_at":"2026-10-31T14:25:46.054672+07:00"}]}
That output was captured from a real Bogie v0.6.8 app; the ids, timestamps and request ids will differ on yours.
That's a working API: a migration, typed queries, validation, a controller and tests, all in plain Go you can read and change. Next, add your own fields with bogie g scaffold, or see the guides for what each piece does.
Want the full walkthrough from zero to production? Read Bogie: How to Go from Zero to Production, or start with the free chapters.