only how to use

install gRPC

go get google.golang.org/grpc@latest

install Protocol Buffers v3

Source

install plugin of go

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

install grpc plugin

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

protocol-buffers 官方 Go 教程

check

$ protoc --version
libprotoc 3.21.8

$ protoc-gen-go --version
protoc-gen-go v1.28.1

$ protoc-gen-go-grpc --version
protoc-gen-go-grpc 1.2.0

full code

https://github.com/jokereven/gRPC

tips

protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/hello_world.proto

windows:

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/hello_world.proto
python3 -m grpc_tools.protoc -Iproto --python_out=. --grpc_python_out=. proto/hello_world.proto

-Iproto is -I + proto file directory, and the python client import package name is like hello_world_pb2 and hello_world_pb2_grpc your proto file name + _pb2 and + _pb2_grpc

references

RPC 原理与 Go RPC

Protocol Buffers V3 中文语法指南[翻译]

protobuf 中使用 oneof、WrapValue 和 FieldMask

gRPC 教程

gRPC-Gateway 使用指南

gRPC Transcoding

Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.