This is a microservice project built using clean architecture principles.
- Clone the repository:
git clone https://github.com/willian2s/clean-go.git
- Build the microservice:
cd clean-go
go build
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
.
To contribute to the development of this microservice, follow these steps:
- Install the required development dependencies:
- Install migrate CLI, and
go install github.com/cosmtrek/air@latest
- 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.
-
Make your changes and write tests for them.
-
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.
- Generate documentation:
- Install the swaggo
go install github.com/swaggo/swag/cmd/swag@latest
- Generate doc:
swag init -d adapter/http --parseDependency --parseInternal --parseDepth 2 -o adapter/http/docs
To run the tests, use the following command:
go test ./...
To generate the coverage report, use the following command:
chmod +x ./coverage.sh
./coverage.sh
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
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.