Install Golang and PostgresSQL. We recommend using a version manager like asdf to manage your installations. Use the versions of the tools listed in the .tool-versions file.
-
(For
asdfonly) if not already installed, install the necessary plugins:asdf plugin add golang asdf plugin add postgres
-
Install the required versions of the tools:
asdf install golang 1.21.5 asdf install postgres 14.8
To work with and debug the API, we also strongly recommend installing tools like Postman.
We use pre-commit and pre-push hooks to ensure that code is formatted and linted before committing and pushing. To set up the hooks, run the following commands:
make hooksNotes:
- Hooks only work on macOS/Linux. Support for Windows is coming soon.
- You will need to install golangci-lint locally for git hooks to work. See Running linter for instructions.
Run the following command to create the database:
make db_createFor this step onwards, make sure you have your environment variables set up correctly. See Setting up environment variables for more details.
Run the migration target to migrate the database:
make db_migrateBy default, the migration target will run all pending migrations (visible using make db_status command). To only run a certain number of migrations forward, use the steps argument:
make db_migrate steps=1To roll back the most recent migration, run the following command:
make db_rollbackTo roll back a certain number of migrations, use the steps argument:
make db_rollback steps=1Copy .env.example to .env and fill in/modify the required values as needed.
make devStep 1: Install golangci-lint locally.
Step 2: Run the lint commmand:
make lintBy convention, test files are named *_test.go and are placed in the same directory as the code they are testing.
To run all tests:
make testTo run all tests and view test coverage:
make coveragemake build