rahmatrdn / go-skeleton

Boilerplate/Skeleton for your Golang projects made with Clean Architecture and Fiber Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Propper Skeleton for your Golang Project

Description

go-skeleton is a boilerplate for Golang projects. The project structure follows the Clean Code Architecture (Read here). This Skeleton made with Fiber Framework.

"Forget about the complexities of folder structures, and concentrate on growing your project!"

Features :

  1. REST API
  2. Clean Architecture
  3. Fiber Framework
  4. Api Docs with Sweager
  5. Worker Queue with RabbitMQ
  6. Implementation of Unit Test (with Testify and Mockery)
  7. Authentication with JWT RS512
  8. GRPC Server! (IN PROGRESS)
  9. GRPC Server with handle authentication (Soon!)
  10. Caching with Redis (Soon!)
  11. Dependency Injection with Google Wire (Soon!)
  12. Worker Queue with Kafka (Soon!)

Feel free to contribute to this repository if you'd like!

Contact

Name Email Role
Rahmat Ramadhan Putra rahmat.putra@spesolution.com Creator

Development Guide

Prerequisite

Windows OS (for a better development experience)

Installation

  1. Clone this repo
git clone https://github.com/rahmatrdn/go-skeleton.git
  1. Copy example.env to .env
cp example.env .env
  1. Adjust the .env file according to the configuration in your local environment, such as the database or other settings
  2. Create a MySQL database with the name go_skeleton.
  3. Run database migration
make migrate_up
  1. Generate private_key.pem and public_key.pem. You can generate them using an Online RSA Generator or other tools. Place the files in the project's root folder.
  2. Start the API Service
go run cmd/api/main.go
  1. Start the Worker Service (if needed)
go run cmd/worker/main.go

Api Documentation

For API docs, we are using Swagger with Swag Generator

  • Install Swag
go install github.com/swaggo/swag/cmd/swag@latest
  • Generate apidoc
make apidoc
  • Start API documentations
go run cmd/api/main.go

Unit test

tips: if you use VS Code as your code editor, you can install extension golang.go and follow tutorial showing code coverage after saving your code to help you create unit test

  • Use Mockery to generate mock class(es)
make mock dependency=DependencyClassName
  • Run unit test with command below or You can run test per function using Vscode!
make test

Running In Docker

  • Docker Build for API
docker build -t go-skeleton-api:1.0.1-dev -f ./deploy/docker/api/Dockerfile .
  • Docker Build for Worker
docker build -t go-skeleton-worker:1.0.1-dev -f ./deploy/docker/worker/Dockerfile .
  • Run docker compose for API and Workers
docker-compose -f docker-compose.yaml up -d

Contributing

  • Create a new branch with a descriptive name that reflects the changes and switch to the new branch. Use the prefix feature/ for new features or fix/ for bug fixes.
git checkout -b <prefix>/branch-name
  • Make your change(s) and make the test(s)
  • Commit and push your change to upstream repository
git commit -m "[Type] a meaningful commit message"
git push origin branch-name
  • Open Merge Request in Repository (Reviewer Check Contact Info)
  • Merge Request will be merged only if review phase is passed.

More Details Information

Contact Creator!

About

Boilerplate/Skeleton for your Golang projects made with Clean Architecture and Fiber Framework


Languages

Language:Go 96.7%Language:Dockerfile 2.3%Language:Makefile 1.0%