Using,
- Go 1.25
- Docker & Docker Compose (for Postgres)
- Chi router: https://github.com/go-chi/chi
- Uber Zap for logging: https://pkg.go.dev/go.uber.org/zap#section-readme
- Migrate CLI for DB migrations: https://github.com/golang-migrate/migrat
- Air for live reloading: https://github.com/air-verse/air
- Go swagger for docs: https://github.com/swaggo/swag
- Frontend (TDB - but Svelte or React)
Quick setup
-
Start the DB
docker-compose up -d
-
Configure the DB connection
- Create a
.envrcor.envwith your DB address. Example (used by Makefile/migrate tools):DB_ADDR=postgres://admin:adminpassword@localhost:5432/social?sslmode=disable - If using direnv, run
direnv allowafter creating.envrc.
- Create a
-
Run migrations
- Using the
migrateCLI:migrate -path=./cmd/migrate/migrations -database="${DB_ADDR}" up - Or use the Makefile:
make migrate-up
- Using the
-
Build and run the API
- Build:
go build -o ./bin/main ./cmd/api/*.go - Run:
./bin/main
- OR just
air
- Build:
Useful commands
- Regenerate docs:
make gen-docs(configured to run with Air eveytime atm) - Seed DB:
make seed - Recreate migrations:
make migration NAME - Run migrations down:
make migrate-down NAME(see Makefile)