This document provides instructions on how to set up and run the Go project using the provided Makefile
commands.
- Go 1.18+
- Make
- Air (for
make air
)
Ensure you have these dependencies installed before running the commands.
Before running the project, ensure that you have the following installed:
- Go 1.18+: The Go programming language (required to run and build the project).
- Air: A live-reloading tool for Go that will automatically restart the project on file changes.
- Make: A build automation tool used to manage tasks defined in the
Makefile
.
- Install Go If you don't have Go installed, follow the official guide to install it:Go Installation Guide.
- Install Make To install Make, follow the installations steps from here based on your OS: Make Installation Guide.
- Install Air To install Air, follow the installation steps here: Air Installation Guide
-
Ensure Docker is installed and running on your machine.
-
Navigate to the project directory.
-
Make sure repo contains a
docker-compose.yml
file with the following content:version: '3.8' services: rabbitmq: image: rabbitmq:3.13-management container_name: rabbitmq ports: - '5672:5672' - '15672:15672'
-
Start the RabbitMQ container:
docker-compose up -d
-
Verify that RabbitMQ is running by accessing the management interface at http://localhost:15672. The default username and password are both
guest
.
There are total 3 variables required to make this service functional
- QUEUE_URL (
amqp://<HOST_NAME>:<PORT>
) The value of HOST_NAME depends on how you're running the project.
- If you're using
docker-compose
for both the queue and consumer, and assuming the queue's container is namedrabbitmq
, setHOST_NAME
torabbitmq
. - If you're running the consumer without
docker-compose
, then setHOST_NAME
tolocalhost
.
- QUEUE_NAME
You can use any name, consider
RDS_QUEUE
for default use case - DISCORD_SERVICE_URL Place URL of Discord Service
-
Install Packages
go mod download
-
Verify Packages If it's your first time running the project, ensure all dependencies are set up:
go mod tidy
-
Running the Project
go run .
-
Running the Project Using Air
air
You can run the project using the Makefile
, which provides several commands for various tasks. Below are the steps to run the project:
-
Install Packages
make download
-
Verify Packages If it's your first time running the project, ensure all dependencies are set up:
make tidy
-
Running the Project
make run
-
Running the Project Using Air
make air
-
To run tests:
make test #or go list ./... | grep -v "/config$$" | grep -v "/routes$$" | xargs go test -v
-
To generate a coverage report:
make coverage #or go list ./... | grep -v "/config$$" | grep -v "/routes$$" | xargs go test -v -coverprofile=coverage.out
-
To automatically re-run the application on changes:
make air #or air
-
To clean up the generated files:
make clean #or rm -rf coverage coverage.out coverage.html