protoc & protoc-gen-go installation
#
Forwardprotoc is a tool written in C++, which can translate proto files into codes in the specified language. In the go-zero microservices, we use grpc to communicate between services, and the writing of grpc requires the use of protoc and the plug-in protoc-gen-go that translates into go language rpc stub code.
Demonstration environment of this document
- mac OS
#
way 1: install from goctl#
way2: install from web page#
protoc installationEnter the protobuf release page and select the compressed package file suitable for your operating system
Unzip
protoc-3.14.0-osx-x86_64.zip
and enterprotoc-3.14.0-osx-x86_64
Move the started
protoc
binary file to any path added to the environment variable, such as$GOPATH/bin
. It is not recommended putting it directly with the next path of the system.tip
$GOPATH is the actual folder address of your local machine
Verify the installation result
#
protoc-gen-* installationtip
Windows may report an error, A required privilege is not held by the client.
, because goctl needs to be run as administrator
under Windows.
The reason is that goctl needs to be run "as administrator" under Windows.
- Download and install
protoc-gen-go
caution
protoc-gen-go installation failed, please read Error