This project is a REST API template in Go using module and dependency injection.
- Clone the repository:
git clone https://github.com/LordPax/golang-module-template.git- Navigate to the project directory:
cd golang-module-template- Start the Docker containers:
docker-compose up- Create a
.envfile in the root of thebackdirectory and add the following environment variables:
NAME='Golang Api'
DOMAIN=localhost:8080
PORT=:8080
GIN_MODE=debug
ALLOWED_ORIGINS='*'
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=root
DB_NAME=golang-app
DB_PORT=5432
COOKIE_SECURE=false
JWT_SECRET_KEY=secret
BREVO_API_KEY=
BREVO_SENDER=noreply@example.com
OS_CLOUD=openstack- Install dependencies:
go mod download
go mod vendor- Build the project:
swag init
go build- Migrate the database:
./golang-api call db:migrate
./golang-api call db:fixtures # optional- Start the server:
./golang-api- Install
graphviz:
- For Debian/Ubuntu:
sudo apt install graphviz- For Arch Linux:
sudo pacman -S graphviz- Generate the dependencies graph:
./golang-api graph
sfdp -Tsvg -o example/graph.svg example/graph.dot