This is a simple tutorial of RPC in Go based on the documentation provided in the package rpc. The example ilustrates the interaction between a server and a client that requests a calc for two numbers based on the operation provided.
- Run
make
- In another terminal run
./calc -op <OP> <A> <B>
.
Note:
- OP is a string, and may be one of the followings: "mult", "sum", "sub", "div".
- A and B are two int numbers.
$ ./calc -op mult 2 3
2 * 3 = 6 // result
$ ./calc -op sum 2 3
2 + 3 = 5 // result
$ ./calc -op sub 2 3
2 - 3 = -1 // result
$ ./calc -op div 201 3
201 / 3 = 67 (quociente), 0 (remainder) // result