This repository contains the reference solution that emerges if you complete every self-study assignment in the course. It demonstrates how to combine SQLite/PostgreSQL, sqlc, goose migrations, CLI tooling, and integration tests in a single Go application.
- CLI commands for managing users, courses, and course membership.
- Prepared statements and transactions for bulk workflows.
- Repository layer (hand-written) on top of
sqlcqueries. - goose migrations covering users, courses, lessons, reviews, and many-to-many relations.
- Environment-driven configuration (
DB_DRIVER,DB_DSN, etc.).
- Go 1.24+.
sqlc(go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest).goose(go install github.com/pressly/goose/v3/cmd/goose@latest).- Docker + Docker Compose (for running PostgreSQL locally).
- GNU Make (optional, but all commands are provided as make targets).
make migrate # apply goose migrations to SQLite
make run CMD=user-create [email protected] NAME=Demodocker compose up -d db
export DB_DRIVER=pgx
export DB_DSN="postgres://app:secret@localhost:6543/app?sslmode=disable&application_name=hexlet-go-sql"
make migrate
make run CMD=course-create COURSE="Graph Theory"Use make rollback to undo the latest migration and make sqlc after editing SQL files.
cmd/app– CLI entrypoint.internal/config– configuration loader and environment variables.internal/repository– data-access layer and transaction helpers.internal/migrate– goose bootstrapper.migrations– SQL migrations consumed by goose.query&sqlc.yaml–sqlcconfiguration and query files.docker-compose.yml– local PostgreSQL instance for development.
make test-integrationTests run against an in-memory SQLite database (or your configured DSN) with the integration build tag, so the production database stays untouched.