go-monorepo

module
v0.0.0-...-deaf358 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT

README

Golang Monorepo

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 of pkg because the modules under lib are meant for direction consumption in the services.

Stack

This repository uses go-chi as a router, it uses sqlc for the DAL and PGX as the DB driver for Postgres.

Setup

pre-commit

We use pre-commit to orchestrate linting.

  1. install pre-commit on your machine.
  2. install the pre-commit hooks by executing pre-commit install in the repository root.
pre-commit commands
  • pre-commit autoupdate to update the hooks
  • pre-commit run --all-files to execute against all files
Docker

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
  1. sqlc.
  2. run sqlc generate or any of the other commands in the root.

Migrations

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.
TaskFile

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL