modulepackage
0.0.0-20240330035812-610cc5f2392b
Repository: https://github.com/rhiadc/ms-base-go.git
Documentation: pkg.go.dev
# README
ms-base-go
Overview
This project is a template managed by the infra-provision-orch.
This GitHub project is a microservice template written in Golang, designed to serve as a starting point for developing microservices using clean architecture and hexagonal design principles. By selecting this template, you get a repository preconfigured with various examples of API implementation, server setup, graceful shutdown, domain modeling, repository patterns, GORM integration, tests using mockgen, and more. Feel free to customize and build upon these examples to create your own microservice tailored to your needs.
Features
- Clean architecture with hexagonal design concepts.
- Examples of API implementation, server setup, graceful shutdown, domain modeling, and repository patterns.
- Integration with GORM for database operations.
- Testable code with the use of mocks generated by mockgen and test-container.
- Command-line interface (CLI) built with Cobra.
- Dockerfile for generating a Docker image of the base microservice.
- Docker Compose configuration for easy deployment.
- Makefile with common tasks for running the project.
Getting Started
To use this microservice template, follow these steps:
- Clone the Repository:
git clone https://github.com/Rhiadc/ms-base-go cd ms-base-go
Customize as needed
- Explore the examples and templates provided.
- Clean and modify the code to fit your project requirements.
Project Structure
The project follows a clean and hexagonal architecture, organized into distinct layers:
- config: Project envs configuration
- api: API layer with HTTP handlers, separate router and server.
- repository: Data access layer with repository interfaces.
- infra: Infrastructure concerns, such as database setup and configurations.
- tests: Unit and integration tests.
Dependencies used
- Golang: https://golang.org/
- GORM: https://gorm.io/
- Cobra: https://github.com/spf13/cobra
- Viper: https://github.com/spf13/viper
- Mockgen: https://github.com/golang/mock/mockgen
- CHI: https://github.com/go-chi/chi
- Testcontainers: https://github.com/testcontainers/testcontainers-go