English | 简体中文
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 .
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