Item | Description |
---|---|
Golang Version | 1.20 |
Object Storage | Cloudinary |
moq | mockgen |
Linter | GolangCI-Lint |
Testing | testing and testify/assert |
Application Architecture | Clean Architecture |
Directory Structure | Standard Go Project Layout |
CI (Lint, Test, Deployment) | GitHubActions |
Logger | logrus |
Database | postgres |
Database Migration | goose |
Key Value Storage | redis |
See the following page to download and install Golang.
You can install all tools for development and deployment for this service by running:
$ go mod download
$ make install
$ cp .env.example .env
note: for cloudinary env, will be provided by separate file
$ go run main.go db:migrate up
$ go run main.go http:start
or
$ make http
$ make test
$ make lint
You can import postman collection from docs/dealls.postman_collection.json
This project follow https://github.com/golang-standards/project-layout
However, for have a clear direction when working in this project, here are some small guide about each directory:
- cmd: main Go file for running the service, producer, consumer, etc.
- config: configuration file for the service.
- database: database migration files.
- development: file to support development like docker-compose.
- docs: file about project documentations such as diagram, sequence diagram, etc.
- internal: internal code that can't be shared.
- internal/adapters/httphandler: adapter layer that serve into gRPC service.
- internal/di: dependencies injection for connecting each layer.
- internal/middleware: middleware for HTTP server.
- internal/consts: constant value that can be shared.
- internal/presentations: presentation that struct for request and response.
- internal/infrastructure: infrastructure layer that connect to database, object storage, etc.
- internal/entities: entity layer that struct for database table.
- internal/usecases: business logic that connect to repository layer, HTTP client, etc.
- pkg: package code that can be shared.
- scripts: shell script, go script to help build or testing something.
This project has GitHub Actions CI to do some automation such as:
- lint: check the code style.
- test: run unit testing and uploaded code coverage artifact.
- deployment: deploy to GCE instance, setup only because not provided by the client.