Three lines in doze.hcl give you a real Postgres. Nothing starts until something connects.
1 · In doze.hcl
doze.hcl
module postgres "postgres" {
version = 18
}
2 · Hand your app the URL
doze.hcl
app"orders" {
run = "go run ./services/orders"
env = { DATABASE_URL = module.postgres.url }
}
Your app sees postgres://postgres@127.0.0.1:5432/postgres?sslmode=disable. The database is named after the instance. doze env prints it for tools outside doze.hcl.
3 · Connect
import (
"context""os""github.com/jackc/pgx/v5/pgxpool"
)
func open(ctx context.Context) (*pgxpool.Pool, error) {
// The first connection wakes Postgres; it can take a moment.return pgxpool.New(ctx, os.Getenv("DATABASE_URL"))
}
import pg from"pg";
// The first connection wakes Postgres; it can take a moment.export const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
import os
import psycopg
# The first connection wakes Postgres; it can take a moment.
conn = psycopg.connect(os.environ["DATABASE_URL"])
A second instance on its own port. Reset wipes its rows; the next connection brings your roles and schemas back. Parallel workers each create and drop their own database inside it.
doze.hcl
module postgres "test" {
version = 18
port = 5433
sleep = "30s"
}
terminal
$ doze reset test --yes
$ doze run -- go test ./...
Extensions
16 extensions by name, coming in postgres 0.3: doze fetches each for your Postgres major and platform. Contrib ones (pg_trgm, uuid-ossp, hstore, citext) ship with Postgres and work now.