Skip to content
/ go-skeleton Public template

Go Skeleton / Go Boilerplate. Project Template for your Golang projects made with Clean Architecture and Fiber Framework

Notifications You must be signed in to change notification settings

rahmatrdn/go-skeleton

Repository files navigation

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 Swagger
  5. Worker Queue with RabbitMQ
  6. Implementation of Unit Test (with Testify and Mockery)
  7. Authentication with JWT RS512
  8. Logging with Zap Log
  9. GRPC Server! (IN PROGRESS)
  10. GRPC Server with handle authentication (Soon!)
  11. Caching with Redis (Soon!)
  12. Dependency Injection with Google Wire (Soon!)
  13. 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 d=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

Go Skeleton / Go Boilerplate. Project Template for your Golang projects made with Clean Architecture and Fiber Framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published