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.

You can install with goctl one click installation protocol,protocol-gen-go,protocol-gen-go-grpc related components, you can execute the following command:

  1. $ goctl env check --install --verbose --force

For more information about goctl env instructions, refer to goctl env

2. Manual installation

2.1 Downloads

protoc installation - 图1NOTE

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.

Microsoft Windows

Windows Intel x86-64 bit processorprotoc-21.11-win64.zip(2.17MB)

Microsoft Windows

Windows Intel x86-32 bit processorprotoc-21.11-win32.zip(2.2MB)

Apple macOS(ARM64)

Support macOS Apple 64-bit processorprotoc-21.11-osx-aarch_64.zip(1.3MB)

Apple macOS(x86-64)

Support macOS 64-bit processorprotoc-21.11-osx-x86_64.zip(1.42MB)

Linux

Support Linux 64 bit processorprotoc-21.11-linux-x86_64.zip(1.51MB)

Linux

Support Linux 32 bit processorprotoc-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:

  1. $ 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:

  1. $ goctl env check --verbose
  2. [goctl-env]: preparing to check env
  3. [goctl-env]: looking up "protoc"
  4. [goctl-env]: "protoc" is installed
  5. [goctl-env]: looking up "protoc-gen-go"
  6. [goctl-env]: "protoc-gen-go" is installed
  7. [goctl-env]: looking up "protoc-gen-go-grpc"
  8. [goctl-env]: "protoc-gen-go-grpc" is installed
  9. [goctl-env]: congratulations! your goctl environment is ready!