This repository is an example monorepo using golang.
Notes:
- Due to the limitations of the go module system, we use a single
go.mod
file at the root level. - We use
lib
instead ofpkg
because the modules underlib
are meant for direction consumption in the services.
This repository uses go-chi as a router, it uses sqlc for the DAL and PGX as the DB driver for Postgres.
We use pre-commit to orchestrate linting.
- install pre-commit on your machine.
- install the pre-commit hooks by executing
pre-commit install
in the repository root.
pre-commit autoupdate
to update the hookspre-commit run --all-files
to execute against all files
There is a dockerfile
in the repository root which uses distroless
as the production image. Use docker compose for local development:
docker compose up --build
- sqlc.
- run
sqlc generate
or any of the other commands in the root.
This project uses goose for database migrations.
- Use the
taskfile
commands to run the database migrations. - Make sure to have
DATABASE_URL
in your *.env file.
There is a Taskfile.yaml
file, which is a task runner. This project uses go-task for running task, and it's pretty simple to use.
- For installation of
taskfile
use these instructions. - For running the tasks run:
task <task-name>
, ex:task greet