This is a proposal for implementing a hexagonal architecture in Go using the most popular frameworks and libs.
The primary goal of this project is to demonstrate how to structure a Go application with a hexagonal architecture using Fiber.
This project is based on and forked from go-gin-clean-arch
In this project, I have aimed to adhere to Golang naming conventions and best practices, including:
- Fiber is a Go web framework built on top of Fasthttp, the fastest HTTP engine for Go. It's designed to ease things up for fast development with zero memory allocation and performance in mind.
- JWT A go (or 'golang' for search engine friendliness) implementation of JSON Web Tokens.
- GORM with PostgresSQLThe fantastic ORM library for Golang aims to be developer friendly.
- Wire is a code generation tool that automates connecting components using dependency injection.
- Koanf is a library for reading configuration from different sources in different formats in Go applications. It is a cleaner, lighter alternative to spf13/viper with better abstractions and extensibility and far fewer dependencies..
- Swag converts Go annotations to Swagger Documentation 2.0 with fiber-swagger and swaggo files
- Testify is a set of packages that provide many tools for testifying that your code will behave as you intend. Features include: easy assertions, mocking, testing suite interfaces and functions, and a test runner.
To use go-proposal-hexagonal-arch
project, follow these steps:
# Navigate into the project
cd ./go-proposal-hexagonal-arch
# Install dependencies
make deps
# Generate wire_gen.go for dependency injection & build the project
# Please make sure you are export the env for GOPATH
make build
# Run the project in Development Mode
make run
Additional commands:
➔ make help
build Generate wire_gen.go && 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
In the project directory, you can call:
For getting status page
For generating a JWT
For getting all of users
For getting user by ID
For creating new user
For removing existing user
For updating existing user