This recipe will illustrate how procedures via the JSON-RPC protocol can be called with use of the standard library.
Calling the JSON-RPC service
How to do it...
- Open the console and create the folder chapter07/recipe11.
- Navigate to the directory.
- Create the jsonrpc.go file with the following content:
package main
import (
"log"
"net"
"net/rpc"
"net/rpc/jsonrpc"
)
type Args struct {
A, B int
}
type Result int
type RpcServer struct{}
func (t RpcServer) Add(args *Args, result *Result) error {
log.Printf("Adding %d to %d\n", args.A, args.B)
*result = Result...