Skip to content

LordPax/godular-api-template

Repository files navigation

Golang module template

Description

This project is a REST API template in Go using module and dependency injection.

Technologies used

Project initialization

  1. Clone the repository:
git clone https://github.com/LordPax/golang-module-template.git
  1. Navigate to the project directory:
cd golang-module-template
  1. Start the Docker containers:
docker-compose up

Backend installation

  1. Create a .env file in the root of the back directory 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
  1. Install dependencies:
go mod download
go mod vendor
  1. Build the project:
swag init
go build
  1. Migrate the database:
./golang-api call db:migrate
./golang-api call db:fixtures # optional
  1. Start the server:
./golang-api

Module dependencies graph

Generate graph

  1. Install graphviz:
  • For Debian/Ubuntu:
sudo apt install graphviz
  • For Arch Linux:
sudo pacman -S graphviz
  1. Generate the dependencies graph:
./golang-api graph
sfdp -Tsvg -o example/graph.svg example/graph.dot

Graph

Module dependencies graph

About

A golang rest api that use module and dependency injection

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors