willian2s / clean-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clean Go Microservice

License: MIT

This is a microservice project built using clean architecture principles.

Table of Contents

Installation

  1. Clone the repository:
  git clone https://github.com/willian2s/clean-go.git
  1. Build the microservice:
  cd clean-go
  go build

Usage

To start the microservice, run the following command:

  go run main.go

or

  ./main

By default, the microservice runs on port 3000. You can access it at http://localhost:3000.

Development

To contribute to the development of this microservice, follow these steps:

  1. Install the required development dependencies:
  go install github.com/cosmtrek/air@latest
  1. Start the hot-reloading development server using Air:
  air

This will start the development server and automatically reload the microservice whenever changes are made to the source files.

  1. Make your changes and write tests for them.

  2. Apply database migrations using golang-migrate/migrate:

  migrate -source file://path/to/migrations -database "YOURDBCONNECTION_STRING" up

Replace path/to/migrations with the actual path to your migrations folder and YOUR_DB_CONNECTION_STRING with the actual connection string for your database. Adjust the command if you're using a different database engine or migration source.

  1. Generate documentation:
  go install github.com/swaggo/swag/cmd/swag@latest
  • Generate doc:
  swag init -d adapter/http --parseDependency --parseInternal --parseDepth 2 -o adapter/http/docs

Testing

To run the tests, use the following command:

  go test ./...

Coverage

To generate the coverage report, use the following command:

  chmod +x ./coverage.sh
  ./coverage.sh

Mocking

Install the mockgen tool:

  go install go.uber.org/mock/mockgen@latest

To create mocks, use the following command:

  mockgen -source ./path/to/source.go -destination ./path/to/destination.go -package=package

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

License:MIT License


Languages

Language:Go 99.5%Language:Shell 0.5%