This is a creation in Article, where the information may have evolved or changed.
Built-in GOB
Rpcserver
package mainimport ( "errors" "FMT" "NET" "Net/rpc" "OS") type args struct { a, b int}type quotient struct { quo, Rem int}type Arith intfunc (T *arith) multiply (args *args, reply *int) error { *reply = args. A * args. b return nil}func (T *arith) divide (args *Args, quo *quotient) error { if args. B == 0 { return errors. New ("Divide by zero") } quo. Quo = args. A / args. B quo. Rem = args. A % args. b return nil}func main () { arith := new (arith) rpc. Register (Arith) tcpaddr, err := net. RESOLVETCPADDR ("TCP", ": 1234") checkerror (Err) listener, err := net. LISTENTCP ("TCP",  TCPADDR) checkerror (err) /* rpc. Accept (Listener) */ for { conn, err := listener. Accept () if err != nil { continue } rpc. SERVECONN (conn) }}func checkerror (Err error) &NBSp { if err != nil { Fmt. Println ("fatal error ", err. Error ()) os. Exit (1) }}
Rpcclient
package mainimport ( "FMT" "Log" "NET/RPC" "OS") type args struct { a, b int}type quotient struct { quo, rem int}func main () { if len (OS. Args) != 2 { fmt. Println ("usage: ", os. args[0], "Server:port") os. Exit (1) } service := os. Args[1] client, err := rpc. Dial ("TCP", service) if err != nil { log. Fatal ("Dialing:", err) } // synchronous call args := args{17,&nBsp;8} var reply int err = client. Call ("Arith.multiply", args, &reply) if err != nil { log. Fatal ("Arith error:", err) } fmt. Printf ("arith: %d*%d=%d\n", args. A, args. b, reply) var quot Quotient err = Client. Call ("Arith.divide", args, ") if err != nil { log. Fatal ("Arith error:", err) } fmt. Printf ("arith: %d/%d=%d remainder %d\n", args. A, args. B, quot. Quo, quot. REM)}
Test
Run./server run./client 127.0.0.1:1234