protoc installation
Overview
protoc is a tool to generate code based on proto files that generate code in multiple languages such as C++, Java, Python, Go, PHP, etc. while gRPC code generation depends on protocol-gen-go,protocol-gen-go-grpc plugin for gRPC code generation in Go language.1. one-click Installation (recommended)
You can install with goctl
one click installation protocol
,protocol-gen-go
,protocol-gen-go-grpc
related components, you can execute the following command:
$ goctl env check --install --verbose --force
For more information about goctl env
instructions, refer to goctl env
2. Manual installation
2.1 Downloads
NOTE
Here we take the 21.11
version as an example, and it is not recommended to install a specific version. Developers can choose according to their needs. For more versions, go to Go to Github to choose by yourself.
Windows Intel x86-64 bit processor
protoc-21.11-win64.zip(2.17MB)Windows Intel x86-32 bit processor
protoc-21.11-win32.zip(2.2MB)Support macOS Apple 64-bit processor
protoc-21.11-osx-aarch_64.zip(1.3MB)Support macOS 64-bit processor
protoc-21.11-osx-x86_64.zip(1.42MB)Support Linux 64 bit processor
protoc-21.11-linux-x86_64.zip(1.51MB)Support Linux 32 bit processor
protoc-21.11-linux-x86_32.zip(1.61MB)Other versions and operating systems can to go to Github to choose.
2.2 Installation
Extract downloads and move them to $GOBIN
directory, see $GOBIN
directory:
$ go env GOPATH
GOBIN
is $GOPATH/bin
, if you $GOPATH
do not $PATH
you need to add it to $PATH
.
3. Validation
Once installed, you can perform the following instructions to verify whether you have installed successfully:
$ goctl env check --verbose
[goctl-env]: preparing to check env
[goctl-env]: looking up "protoc"
[goctl-env]: "protoc" is installed
[goctl-env]: looking up "protoc-gen-go"
[goctl-env]: "protoc-gen-go" is installed
[goctl-env]: looking up "protoc-gen-go-grpc"
[goctl-env]: "protoc-gen-go-grpc" is installed
[goctl-env]: congratulations! your goctl environment is ready!