- Create a file
.env
similar to.env.example
at the root directory with your configuration. - Install
go
if not installed on your machine. - Install
MongoDB
if not installed on your machine. - Important: Change the
DB_HOST
tolocalhost
(DB_HOST=localhost
) in.env
configuration file.DB_HOST=mongodb
is needed only when you run with Docker. - Run
go run .
.
there is an example for kafka controller on WikiJs on path backend/boilerplates/go-kafka-template/readme
# Run all tests
go test ./...
In this project, to test, we need to generate mock code for the use-case, repository, and database.
# Generate mock code for the usecase and repository
mockery --dir=domain --output=domain/mocks --outpkg=mocks --all
# Generate mock code for the database
mockery --dir=mongo --output=mongo/mocks --outpkg=mocks --all
Whenever you make changes in the interfaces of these use-cases, repositories, or databases, you need to run the corresponding command to regenerate the mock code for testing.