Skip to content

Golang microservice template. Clean Architecture, HTTP and GRPC Example, isolation integration tests, isolation unit tests, and database connection pooling.

Notifications You must be signed in to change notification settings

Hidayathamir/go-user

Repository files navigation

go-user

Golang microservice template. Clean Architecture, HTTP and GRPC Example, isolation integration tests, isolation unit tests, and database connection pooling.

Features

  • Clean architecture implementation.
    • Controller, usecase, repository layer separation.
  • HTTP and GRPC example in controller layer.
  • Isolation integration tests using containers.
  • Isolation unit tests with mock support.
  • Database connection pooling.

Code structure

├── config/             contains the application configuration.
├── internal/
│   ├── app/            contains the application starter.
│   ├── controller/     contains the presentation layer and handles incoming requests from clients.
│   │   ├── http/
│   │   ├── grpc/
│   ├── usecase/        contains the application business layer.
│   ├── repo/           contains the data access layer.
│   ├── entity/         contains the domain model.
├── go.mod
├── go.sum
├── main.go
├── README.md

For presentation layer: Some people call it controller (in our case), delivery, transport, or handler.

For business layer: Some people call it usecase (in our case), service, domain, or application.

For data access layer: Some people call it repo/repository (in our case), or persistence.

Get Started

Run application

Run postgres container.

make compose-up-postgres

Run go app.

make go-run

Run test

Test can be without the need to run the application.

Run test integration.

make go-test-integration

Run test unit.

make go-test-unit

Run for deployment

For deployment. Run postgres container also build and run go app container.

make deploy

Other command

See Makefile.

About

Golang microservice template. Clean Architecture, HTTP and GRPC Example, isolation integration tests, isolation unit tests, and database connection pooling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published