A Gin 1.12 CRUD API starter for Go 1.25 that stores one resource, items, in PostgreSQL through pgx v5 and its pgxpool connection pool. It is for Go developers who want list, get, create, replace and delete endpoints with validation, JSON errors, a database health check, slog request logs, graceful shutdown and tests that need no database.
by Light CloudCRUD APIs
main.go reads PORT, GIN_MODE and the DB_* variables, builds a postgres:// URL, opens the pool and creates the table before the http.Server starts, so an unreachable database shows up at deploy time rather than on the first request. The SQL is a handful of hand-written queries in internal/store/store.go, request parsing lives in internal/server/request.go, and each handler is a few lines that call the store and answer with c.JSON. Adding a column means changing the CREATE TABLE, the Item struct, the queries and parseItem, plus one ALTER TABLE on a database that already has the table. On Light Cloud the Go module is built and run as a container on the platform's PORT with the DB_* variables set, and every push to your copy redeploys.
This starter does it in internal/config and internal/store: the DB_* variables become a postgres:// URL with sslmode and pool_max_conns=5, and pgxpool.New opens the pool. Locally, copy .env.example to .env and make run loads it.
Add its queries to a store in internal/store modelled on store.go, add the methods to the Store interface in internal/server/server.go, write handlers and validation next to the item ones and register the routes in server.New.
No. make test runs go vet and go test; the route tests in internal/server use an in-memory store and the tests in internal/config only check the database URL.
Each query is a few lines of SQL, which keeps the starter small and shows exactly what runs against the database. You can add GORM or sqlc later, since the handlers only see the Store interface.
Yes. make build writes a static binary to bin/server; run it with PORT and the DB_* variables set on any server or container platform that can reach PostgreSQL. The repo has no Dockerfile, so add one if your host needs an image.
Start a Go API with Gin routing, slog request logs, panic recovery and route tests
Start a Go JSON API on the standard library alone, with logs, tests and a Dockerfile

Start a Java CRUD API on PostgreSQL with Spring Boot, Swagger UI and Bean Validation