Golang net/rpc.Client.Go() function example
package net/rpc
Golang net/rpc.Client.Go() function usage example
type Args struct {
A, B int
}
type Reply struct {
C int
}
args := Args{8, 8}
mulReply := new(Reply)
mulCall = client.Go("Operator.Multiply", args, mulReply, nil)
addReply := new(Reply)
addCall = client.Go("Operator.Addition", args, addReply, nil)
addCall = <-addCall.Done
if addCall.Error != nil {
fmt.Printf("Addition : expected no error but got string %q", addCall.Error.Error())
}
if addReply.C != args.A+args.B {
fmt.Printf("Addition : got %d expected %d", addReply.C, args.A+args.B)
}
mulCall = <-mulCall.Done
if mulCall.Error != nil {
fmt.Printf("Multiply : expected no error but got string %q", mulCall.Error.Error())
}
if mulReply.C != args.A*args.B {
fmt.Printf("Multiply : got %d expected %d", mulReply.C, args.A*args.B)
}
References :
Advertisement
Something interesting
Tutorials
+5.8k Javascript : How to replace HTML inside <div>?
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+9.1k Golang : Gonum standard normal random numbers example
+22.9k Golang : Test file read write permission example
+9.6k Golang : Sort and reverse sort a slice of floats
+9.6k Golang : How to generate Code 39 barcode?
+25.6k Golang : convert rune to integer value
+14k Golang : Compress and decompress file with compress/flate example
+9.5k Golang : Convert(cast) string to int64
+33.7k Golang : All update packages with go get command
+20.2k Golang : How to get own program name during runtime ?
+16.6k Golang : Delete files by extension