Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hidayathamir/go-user

Golang microservice template. Clean Architecture, HTTP and GRPC Example, isolation integration tests, isolation unit tests, and database connection pooling.
https://github.com/hidayathamir/go-user

clean-architecture clean-code go golang grpc integration-testing microservice repository-pattern rest-api unit-testing

Last synced: 10 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# go-user

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

# Features

- [x] Clean architecture implementation.
- [x] Controller, usecase, repository layer separation.
- [x] HTTP and GRPC example in controller layer.
- [x] Isolation integration tests using containers.
- [x] Isolation unit tests with mock support.
- [x] 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`.