English | 简体中文
This is a collection of commonly used gRPC knowledge points, perfect for comprehensive learning and usage of gRPC. These gRPC knowledge points are extracted from the Go development framework sponge.
Sponge is a powerful development framework that integrates automatic code generation
, gin
and gRPC
frameworks. It greatly improves development efficiency and reduces development difficulty by providing one-stop project development from code generation, development, testing, API documentation to deployment, realizing "low-code" development projects.
Sponge Repo: https://github.com/zhufuyi/sponge
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.
-
Copy the protobuf file dependency folder include to the
$GOBIN
directory. -
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
.
- 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
- Serialization and deserialization of protobuf
- 4 ways of calling in helloworld demo
- interceptor
- recovery
- logging
- keepalive
- metadata set and read
- timeout
- swagger
- tag
- validate
- wait for ready
- http to grpc
- security
- register and discovery
- load-balance
- ratelimit
- breaker
- retry
- metrics
- tracing
- practical project use