Hi Go Experts,
I just encountered this, can one one help advise if that is the expected/right behavior for Go?
type Reply struct {
a int
b int
}
// Server-side code
func (s *Server) Receiver(args *Request, reply *Reply) {
// I do print the reply here, it is { 0, 0 }, which is new,
// not inherit any values from Client, which makes sense,
// after all, it is a reply not a request
reply.a = 0
reply.b = 0
}
// Client-side code
reply := Reply{ -1,-1 }
rpcClient.call( ....., &reply)
// expect reply.a and reply.b being 0, but found a is 0 but b is still -1
I know this may not be a good coding practice, reply’s values (even default) should set and come from server. I should have coded below
var reply Reply
rpcClient.call( ....., &reply)
// now both reply.a and reply.b are 0, which is expected
But just don’t understand how this issue happens, is there any race condition happening in unmarshalling the reply? Trying to debug this issue for many hours already