Open In App

How to Install gRPC in Golang?

Last Updated : 16 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

gRPC is RPC (Remote Protocol Communication) framework that was introduced by Google in the year 2015. The client-server communication is done with the help of procedure/functional calls. gRPC is very popular because its calls are easier to understand and mostly it doesn’t require separate documentation as the majority of them are self-explanatory. Moreover, it has really high performance therefore, it’s quite useful in the microservices. 

Features of gRPC

  • gRPC procedure calls are way faster than HTTP calls
  • gRPC calls are easy to understand therefore, there’s not much documentation needed.
  • It’s really useful for services that require Real-time communication.

Install Protocol Buffer

To install gRPC first you will have to download the protocol buffer as many applications will need it.

For Linux use the following statement to install the protocol buffer

$ apt install -y protobuf-compiler

Now to check if the protocol buffer is installed or not
$ protoc –version

For MacOS users please follow the below statement to install the protocol buffer using Homebrew

$ brew install protobuf

Now to check if the protocol buffer is installed or not
$ protoc –version 

Another method of installing Protocol Buffer

Step 1: Open the link – https://github.com/protocolbuffers/protobuf/releases/tag/v22.3 & download the zip according to the operating system.

Download the zip as per the OS

Download the zip as per the OS

Step 2: Now, you should be able to see the zip in your downloads folder. In my case, I have Windows 64-bit OS so I have downloaded that zip.

Downloaded Zip

Downloaded Zip

Step 3: Unzip the file into the choice of your directory.

Extract to your wish of directory

Extract to your wish of directory

Step 4: Set the environment variable (for Windows) in my case it’s C:\bin. 

Set the environment variable (for Windows) in my case it's C:\bin.

 

Also Check,

How to Install Protocol Buffer in Windows

How to Install Protocol Buffer in Ubuntu

Installation of the gRPC for GO

Now to install the gRPC follow the below commands. We are using the install command to download gRPC.

$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28

$  go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

After the execution of the above command, the command prompt should look like the below image

gRPC for GO installation window

gRPC for GO installation window

If you are a beginner then please set up the GOPATH variable on your computer (it’s a recommendation)

For Windows

Step 1: Open the Environment Variable Windows.

Step 2: Create a new Variable and name GOPATH and now add the path to the Go folder. In my case, it was C:\ProgramFiles\Go because that is where I had installed Go. This should look like below:

 In my case, it was C:\ProgramFiles\Go because that is where I had installed Go.

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads