https://github.com/thnkrn/go-gin-clean-arch
Golang REST API service with Gin framework, Wire for dependency injection, integrating with GORM for ORM libray, Viper for configuration and Swag for creating Swagger documentation by applying clean architecture
https://github.com/thnkrn/go-gin-clean-arch
clean-architecture gin go golang gorm jwt swagger viper wire
Last synced: about 1 hour ago
JSON representation
Golang REST API service with Gin framework, Wire for dependency injection, integrating with GORM for ORM libray, Viper for configuration and Swag for creating Swagger documentation by applying clean architecture
- Host: GitHub
- URL: https://github.com/thnkrn/go-gin-clean-arch
- Owner: thnkrn
- Created: 2022-02-10T06:47:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T08:28:48.000Z (over 3 years ago)
- Last Synced: 2024-11-14T14:48:34.367Z (11 months ago)
- Topics: clean-architecture, gin, go, golang, gorm, jwt, swagger, viper, wire
- Language: Go
- Homepage:
- Size: 87.9 KB
- Stars: 48
- Watchers: 1
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clean Architecture using Golang with Gin framework
## Template Structure
- [Gin](github.com/gin-gonic/gin) is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin.
- [JWT](github.com/golang-jwt/jwt) A go (or 'golang' for search engine friendliness) implementation of JSON Web Tokens.
- [GORM](https://gorm.io/index.html) with [PostgresSQL](https://gorm.io/docs/connecting_to_the_database.html#PostgreSQL)The fantastic ORM library for Golang aims to be developer friendly.
- [Wire](https://github.com/google/wire) is a code generation tool that automates connecting components using dependency injection.
- [Viper](https://github.com/spf13/viper) is a complete configuration solution for Go applications including 12-Factor apps. It is designed to work within an application, and can handle all types of configuration needs and formats.
- [swag](https://github.com/swaggo/swag) converts Go annotations to Swagger Documentation 2.0 with [gin-swagger](https://github.com/swaggo/gin-swagger) and [swaggo files](github.com/swaggo/files)## Using `go-gin-clean-arch` project
To use `go-gin-clean-arch` project, follow these steps:
```bash
# Navigate into the project
cd ./go-gin-clean-arch# Install dependencies
make deps# Generate wire_gen.go for dependency injection
# Please make sure you are export the env for GOPATH
make wire# Run the project in Development Mode
make run
```Additional commands:
```bash
➔ make help
build Compile the code, build Executable File
run Start application
test Run tests
test-coverage Run tests and generate coverage file
deps Install dependencies
deps-cleancache Clear cache in Go module
wire Generate wire_gen.go
swag Generate swagger docs
help Display this help screen
```## Available Endpoint
In the project directory, you can call:
### `GET /`
For getting status page
### `POST /login`
For generating a JWT
### `GET /api/users`
For getting all of users
### `GET /api/users/:id`
For getting user by ID
### `POST /api/users`
For creating new user
### `DELETE /api/users/:id`
For removing existing user
### `PUT /api/users/:id`
For updating existing user