Giter Club home page Giter Club logo

go-grpc-boilerplate's Introduction

go-grpc-boilerplate ๐Ÿš€

Getting Started

Prerequisites

  • Go 1.21
  • Docker
  • sonar-scanner - for coverage test in local
    brew install sonar-scanner

Installation

  1. Clone the repo
    git clone https://github.com/kondohiroki/go-grpc-boilerplate
  2. Install Go dependencies
    go mod tidy
  3. Copy the default configuration file
    cp config/config.example.yaml config/config.yaml
  4. Start the database
    docker compose up -d
  5. Migrate database
    go run main.go migrate
  6. Run the application
    # Run normally
    go run main.go serve:grpc-api
    
    # Run with hot reload
    air serve:grpc-api
  7. 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

Protobuf

  1. Install protobuf compiler

    brew install protobuf
  2. Install the protocol compiler plugins for Go

    $ go install google.golang.org/protobuf/cmd/[email protected]
    $ go install google.golang.org/grpc/cmd/[email protected]
  3. Update your PATH so that the protoc compiler can find the plugins:

    export PATH="$PATH:$(go env GOPATH)/bin"
  4. Compile the proto file to generate the gRPC code

    make pb
  5. Make sure all dependencies are installed

    go mod tidy

Before commit

  1. Please correct your git username and email
    git config user.name "John Doe"
    git config user.email "[email protected]"
  2. 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

go-grpc-boilerplate's People

Contributors

kondohiroki avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.