- Go 1.21
- Docker
- sonar-scanner - for coverage test in local
brew install sonar-scanner
- Clone the repo
git clone https://github.com/kondohiroki/go-grpc-boilerplate
- Install Go dependencies
go mod tidy
- Copy the default configuration file
cp config/config.example.yaml config/config.yaml
- Start the database
docker compose up -d
- Migrate database
go run main.go migrate
- Run the application
# Run normally go run main.go serve:grpc-api # Run with hot reload air serve:grpc-api
- Testing (optional)
# Run unit-test make unit-test # Run api-test make api-test # Create sonar scret touch .sonar.secret echo "your-sonar-token" > .sonar.secret # Add secret to .sonar.secret # Get from sonar web
-
Install protobuf compiler
brew install protobuf
-
Install the protocol compiler plugins for Go
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 $ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
-
Update your PATH so that the protoc compiler can find the plugins:
export PATH="$PATH:$(go env GOPATH)/bin"
-
Compile the proto file to generate the gRPC code
make pb
-
Make sure all dependencies are installed
go mod tidy
- Please correct your git username and email
git config user.name "John Doe" git config user.email "john@email.com"
- Please squash&rebase your commits
# Make sure that base branch is up-to-date git checkout main git fetch git pull # Back to your branch git checkout <your-feature-branch> # =====> SQUASH <===== git reset $(git merge-base origin/main $(git branch --show-current)) git add -A git commit -m "[ISSUE-ID] Add auth api configuration" git push -f # =====> REBASE <===== git rebase origin/main # After resolving conflicts, continue the rebase process git rebase --continue # Force-push the rebased feature branch to the remote repository git push -f