Remote Procedure Call (RPC) is a method of calling the execution of an application functionality from another system, using the TCP protocol. Go has native support for RPC servers.
RPC servers
Defining a service
The Go RPC server permits us to register any Go type, along with its methods. This exposes the methods with the RPC protocol and enables us to call them by name from a remote client. Let's create a helper for keeping track of our progress in the book as we are reading:
// Book represents a book entry
type Book struct {
ISBN string
Title, Author string
Year, Pages int
}
// ReadingList keeps tracks of books and pages read
type ReadingList struct {
Books []Book
Progress []int
}
First, let's define...