/grpc_examples

Rich examples of grpc usage, helps you learn and use grpc more easily.

Primary LanguageGoMIT LicenseMIT

English | 简体中文

GRPC Examples

This is an example of commonly used knowledge in gRPC, very suitable for users who want to learn grpc in a comprehensive and in-depth way. These knowledge points have been applied to the development framework sponge.

Sponge is a basic development framework that integrates code auto generation, Gin and GRPC framework. It is easy to build a complete project from development to deployment, just fill in the specific business logic code on the generated template code, the use of Go can also be "low-code development".

Github Repo: https://github.com/zhufuyi/sponge .


Quick Start

Go Configuration

This step can be skipped if go has already been set up.

# Linux or MacOS
export GOROOT="/opt/go"     # your go installation directory
export GOPATH=$HOME/go      # Set the directory where the "go get" command downloads third-party packages
export GOBIN=$GOPATH/bin    # Set the directory where the executable binaries are compiled by the "go install" command.
export PATH=$PATH:$GOBIN:$GOROOT/bin  # Add the $GOBIN directory to the system path.


# Windows
setx GOPATH "D:\your-directory"      # Set the directory where the "go get" command downloads third-party packages
setx GOBIN "D:\your-directory\bin"   # Set the directory where the executable binary files generated by the "go install" command are stored.

Installation of Protoc and Plugins

  1. Copy the protobuf file dependency folder include to the $GOBIN directory.

  2. Download protoc from: https://github.com/protocolbuffers/protobuf/releases/tag/v25.2

Download the protoc binaries according to the system type, move the protoc binaries to $GOBIN.

  1. Install Protoc Plugins
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
go install github.com/envoyproxy/protoc-gen-validate@latest
go install github.com/mohuishou/protoc-gen-go-gin@latest
go install github.com/srikrsna/protoc-gen-gotag@latest

List of examples