Install protoc
Install protoc
Section titled “Install protoc”RPC services in go-zero use protobuf. You need three components:
protoc— the protobuf compilerprotoc-gen-go— generates Go types from.protofilesprotoc-gen-go-grpc— generates gRPC service stubs
goctl can install the last two for you automatically.
Install protoc
Section titled “Install protoc”brew install protobuf# Find the latest release at https://github.com/protocolbuffers/protobuf/releasesPB_VERSION=27.2wget https://github.com/protocolbuffers/protobuf/releases/download/v${PB_VERSION}/protoc-${PB_VERSION}-linux-x86_64.zipunzip protoc-${PB_VERSION}-linux-x86_64.zip -d $HOME/.localexport PATH=$PATH:$HOME/.local/binWindows
Section titled “Windows”Download protoc-*.zip from the releases page and add the bin/ folder to PATH.
Install Go plugins via goctl
Section titled “Install Go plugins via goctl”goctl automates installing protoc-gen-go and protoc-gen-go-grpc:
goctl env check --install --verboseExpected output:
[goctl-env]: preparing ...[goctl-env]: go out ...[goctl-env]: grpc out ...[goctl-env]: Done.Verify Everything
Section titled “Verify Everything”protoc --version# libprotoc 27.2
protoc-gen-go --version# protoc-gen-go v1.34.2
protoc-gen-go-grpc --version# protoc-gen-go-grpc 1.4.0