Member-only story
What Are RPCs in Golang?
An overview of remote procedure calls in Go

What Is an RPC?
A Remote Procedure Call (RPC) is a subroutine in distributed computing. The remote implementation of RPC is similar to local calls but usually not identical. RPC usually requires that the object name, function name, or parameter are passed to remote servers, and the servers then return the processed result(s) back to client-side (request-response). RPC can be communicated through TCP, UDP, or HTTP protocols.

There are three types of implementation in Golang, namely:
net/rpc
net/rpc/jsonrpc
gRPC
net/rpc
The Golang official documentation uses encoding/gob
in the net/rpc
package as encoding or decoding methods, supporting TCP or HTTP protocols. However, because gob
encoding is only used in Golang, it only supports servers and client-side interactions written in Golang.
Example of server-side net/rpc
:
package mainimport ( "fmt"