Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/rpc: API Call() is not working as expected #29360

SagarPuneria opened this issue Dec 20, 2018 · 3 comments


Copy link

commented Dec 20, 2018

What version of Go are you using (go version)?

$ go version
go version go1.11.4 windows/386

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

Windows 10, 64 bit

What did you do?

I am using client.Call(serviceMethod string, args interface{}, reply interface{}) in my code for implementing HTTP RPC client program, where i have passed reference address of variable in both second parameter args(interface type) and third parameter reply(interface type). So that changes made to the receiver's methods in the DefaultServer get reflected outside the client.Call() method.
HTTP RPC client example

arg:"go version is go1.11.3 is not latest"
reply:"go version is go1.11.4 is latest"

HTTP RPC server example

Inside StringModify

What did you expect to see?

I expected to see the same string values to args and reply(both are interface type) after successfully calling client.Call(). Since i assigned same value at line number 20 as shown in HTTP RPC server example

What did you see instead?

After calling client.Call() args and reply string values are different. I see only reply get modified but not args.


This comment has been minimized.

Copy link

commented Dec 20, 2018

@ALTree ALTree added this to the Go1.13 milestone Dec 21, 2018


This comment has been minimized.

Copy link

commented Dec 23, 2018

I don't think this is an implementation bug, the documentation says the method should be of the form:

func (t *T) MethodName(argType T1, replyType *T2) error

I interpret that as T1 being immutable through the RPC. I would be surprised if T1 was mutated even when it is a pointer. The Arith example uses both arguments as pointer types, perhaps this suggests mutability.

	type Arith int

	func (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

Nowhere in the example is args actually modified though. It might be less confusing to make the example have a value type for args to make things unambiguous.


This comment has been minimized.

Copy link

commented Dec 26, 2018

@as, thanks for investigating.

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.