https://github.com/gbrayhan/microservices-go
Golang Microservice Boilerplate using MySQL, Docker and Swagger, API REST. Gin Go and GORM with pagination and implementation of a Clean Architecture.
https://github.com/gbrayhan/microservices-go
boilerplate boilerplate-go boilerplate-golang boilerplate-microservice clean-architecture docker gin go golang golang-examples gorm hexagonal-architecture jwt microservices-architecture pagination rest-api swagger
Last synced: 24 days ago
JSON representation
Golang Microservice Boilerplate using MySQL, Docker and Swagger, API REST. Gin Go and GORM with pagination and implementation of a Clean Architecture.
- Host: GitHub
- URL: https://github.com/gbrayhan/microservices-go
- Owner: gbrayhan
- License: mit
- Created: 2020-02-14T00:14:43.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T17:46:15.000Z (about 1 month ago)
- Last Synced: 2025-04-28T17:46:52.982Z (about 1 month ago)
- Topics: boilerplate, boilerplate-go, boilerplate-golang, boilerplate-microservice, clean-architecture, docker, gin, go, golang, golang-examples, gorm, hexagonal-architecture, jwt, microservices-architecture, pagination, rest-api, swagger
- Language: Go
- Homepage:
- Size: 434 KB
- Stars: 609
- Watchers: 4
- Forks: 69
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Golang Microservices Boilerplate - Clean Architecture
[](https://github.com/gbrayhan/microservices-go/tree/master/.github/ISSUE_TEMPLATE)
[](https://github.com/gbrayhan/microservices-go/network/members)
[](https://github.com/gbrayhan/microservices-go/stargazers)
[](https://github.com/gbrayhan/microservices-go/tree/master/LICENSE)
[](https://www.codefactor.io/repository/github/gbrayhan/microservices-go/overview/main)
[](https://www.codacy.com/gh/gbrayhan/microservices-go/dashboard?utm_source=github.com&utm_medium=referral&utm_content=gbrayhan/microservices-go&utm_campaign=Badge_Grade)Example structure to start a microservices project with golang. Using a MySQL databaseSQL. Using a Hexagonal
Architecture tha is a Clean Architecture.## Manual Installation
If you would still prefer to do the installation manually, follow these steps:
Clone the repo:
```bash
git clone https://github.com/gbrayhan/microservices-go
```**TL;DR command list**
git clone https://github.com/gbrayhan/microservices-go
cd microservices-go
cp .env.example .env
docker-compose up --build -d## Table of Contents
- [Features](#features)
- [Commands](#commands)
- [Environment Variables](#environment-variables)
- [Project Structure](#project-structure)
- [API Documentation](#api-documentation)
- [Error Handling](#error-handling)
- [Validation](#validation)
- [Linting](#linting)## Features
- **Golang v1.24.2**: Stable version of go
- **Framework**: A stable version of [gin-go](https://github.com/gin-gonic/gin)
- **Token Security**: with [JWT](https://jwt.io)
- **SQL databaseSQL**: [Postgresql](https://www.postgresql.org/) using internal sql package of
go [sql](https://golang.org/pkg/databaseSQL/sql/)
- **Testing**: unit and integration tests using package of go [testing](https://golang.org/pkg/testing/)
- **API documentation**: with [swaggo](https://github.com/swaggo/swag) @latest version that is a go implementation
of [swagger](https://swagger.io/)
- **Dependency management**: with [go modules](https://golang.org/ref/mod)
- **Docker support**
- **Code quality**: with [CodeFactor](https://www.codefactor.io/) and [Codacy](https://www.codacy.com/)
- **Linting**: with [golangci-lint](https://golangci-lint.run/usage/install/) an implementation of a Golang linter## Security Checks using Trivy
https://github.com/aquasecurity/trivy?tab=readme-ov-file
command:
```bash
trivy fs .
```## Commands
### Build and run image of docker
```bash
docker-compose up --build -d
```### Swagger Implementation
```bash
swag init -g src/infrastructure/rest/routes/routes.go
```To visualize the swagger documentation on local use
http://localhost:8080/v1/swagger/index.html
To see the postman collection use
https://www.postman.com/kts-mexico/workspace/boilerplategomicroservice### Unit test command
```bash
# run recursive test
go test ./test/unit/...
# clean go test results in cache
go clean -testcache
```### Lint inspection of go
```bash
golangci-lint run ./...
```