Code Monkey home page Code Monkey logo

microservices-go's Introduction

Golang Microservices Boilerplate - Clean Architecture

issues forks stars license CodeFactor Codacy Badge

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:

git clone https://github.com/gbrayhan/microservices-go

If you need, configure the environment variables in file config.json, if you use docker-compose leave the variables set in the file config.json.example

cp config.json.example config.json

TL;DR command list

git clone https://github.com/gbrayhan/microservices-go
cd microservices-go
cp config.json.example config.json
docker-compose up  --build  -d

Table of Contents

Features

  • Golang v1.21: Stable version of go
  • Framework: A stable version of gin-go
  • Token Security: with JWT
  • SQL databaseSQL: MariaDB using internal sql package of go sql
  • Testing: unit and integration tests using package of go testing
  • API documentation: with swaggo @latest version that is a go implementation of swagger
  • Dependency management: with go modules
  • Environment variables: using viper
  • Docker support
  • Code quality: with CodeFactor and Codacy
  • Linting: with golangci-lint an implementation of a Golang linter

Commands

Build and run image of docker

docker-compose up  --build  -d

Swagger Implementation

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

# run recursive test
go test  ./test/unit/...
# clean go test results in cache
go clean -testcache

Lint inspection of go

golangci-lint run ./...

microservices-go's People

Contributors

abel-garcia avatar dependabot[bot] avatar gbrayhan avatar govilkargaurav avatar lexuanquynh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

microservices-go's Issues

POST /user returns `Invalid Token` error

I've just started to mess around with this template and I'm not fully experienced with how Golang works quite yet but I'm having trouble getting the /user endpoint to successfully create a new user due to a missing/invalid token within the authorization header. I'm not sure what the value could be or where it's located in the project (I assume it's in config.json) so I appreciate any help that I can get.

Response with a random value:

{
    "error": "Invalid token"
}

Response with no value:

{
    "error": "Token not provided"
}

relevant Secure config values (all default values):

{
    "Secure": {
	"JWTAccessSecure": "accesskeyyoumayneedtochangeit",
	"JWTRefreshSecure": "refreshkeyyoumayneedtochangeit",
	"JWTAccessTimeMinute": 10,
	"JWTRefreshTimeHour": 10
    },
}

Incorrect docs.go after swag init

Describe the bug
Whenever I do swag init -g routes/ApplicationV1.go the resulting docs.go is incorrect and doesn't look like the previous one.

To Reproduce
Steps to reproduce the behavior:

  1. run swag init -g routes/ApplicationV1.go
  2. verify docs.go
  3. missing structs and most of the one that is there swag.Spec is unresolved.

Expected behavior
The docs.go should update correctly

Screenshots
image

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
I just started using the Template and have ran go get to download all the mods. I have also installed swag/cmd but I am unaware of the correct version to use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.