Go provides your system with basic RPC functionality with the net/rpc package. This is a potential alternative to making RPC calls without relying on GRPC or other more complex RPC packages. However, its functionality is rather limited and any function you may wish to export must conform to a very specific function signature.
The comments in the code note some of these restrictions for a method that can be called remotely. This recipe demonstrates how to create a shared function that has a number of parameters passed in via a structure and can be called remotely.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application, create a new directory called~/projects/go-programming-cookbook/chapter5/rpcand navigate to this directory.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go...