type Arith int func (t *Arith) Multiply(args *Args, reply *int) error { *reply = args.A * args.B return nil }
type Args struct { A, B int } type Result struct { Res int } func main() { client, err := rpc.Dial("tcp", "localhost:1234") if err != nil { log.Fatal("dialing:", err) } args := &Args{7, 8} var res Result err = client.Call("Arith.Multiply", args, &res) if err != nil { log.Fatal("arith error:", err) } fmt.Printf("Arith: %d*%d=%d", args.A, args.B, res.Res) }In this example, we define a client that dials the RPC server and calls the Multiply method with arguments Args{7,8}. The response from the server is assigned to a Result struct. The final output will display the result of the multiplication.