You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I attempted to register, net/rpc Register, a type which contains some public methods that should be exposed as RPC methods, and some methods that are public but shouldn't be exposed as RPC methods. According to the net/rpc documentation...
Only methods that satisfy these criteria will be made available for
remote access; other methods will be ignored:
- the method's type is exported.
- the method is exported.
- the method has two arguments, both exported (or builtin) types.
- the method's second argument is a pointer.
- the method has return type error.
... a public method that has only one argument should be ignored, but instead an error message is printed when such a method is encountered. Please see this example which reproduces the behaviour.
What did you expect to see?
Nothing should be printed.
What did you see instead?
From the go playground example above 2009/11/10 23:00:00 method ShouldNotBeExposedByRPC has wrong number of ins: 2
Suggested solution
In net/rpc/server.go:262 the function suitableMethods is called with reportErr=true, this eventually causes the printout, see net/rpc/server.go:298. If methods don't satisfy the criteria for exposure they should be ignored as the documentation says.
The text was updated successfully, but these errors were encountered:
odeke-em
changed the title
net/rpc reports error when it shouldn't
net/rpc: error reported in server, when it shouldn't
Jul 21, 2017
Tagging this for Go1.10. This a bug report and not a feature request so I don't think that affects whether net/rpc is frozen, what do y'all think: @robpike@adg?
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
I attempted to register,
net/rpc Register
, a type which contains some public methods that should be exposed as RPC methods, and some methods that are public but shouldn't be exposed as RPC methods. According to the net/rpc documentation...... a public method that has only one argument should be ignored, but instead an error message is printed when such a method is encountered. Please see this example which reproduces the behaviour.
What did you expect to see?
Nothing should be printed.
What did you see instead?
From the go playground example above
2009/11/10 23:00:00 method ShouldNotBeExposedByRPC has wrong number of ins: 2
Suggested solution
In
net/rpc/server.go:262
the functionsuitableMethods
is called withreportErr=true
, this eventually causes the printout, seenet/rpc/server.go:298
. If methods don't satisfy the criteria for exposure they should be ignored as the documentation says.The text was updated successfully, but these errors were encountered: