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: returned error values fail comparison check #12695

Closed
RomanSaveljev opened this issue Sep 19, 2015 · 3 comments
Closed

net/rpc: returned error values fail comparison check #12695

RomanSaveljev opened this issue Sep 19, 2015 · 3 comments

Comments

@RomanSaveljev
Copy link

I have go version go1.5.1 linux/amd64

Say, server part returns io.EOF from an exported method, the error is received on the client side and there err == io.EOF is false instead of true

This small program demonstrates the issue: http://play.golang.org/p/eWECxr-OLa

I expected:

2009/11/10 23:00:00 EOF == EOF is true
2009/11/10 23:00:00 EOF == EOF is true

I got:

2009/11/10 23:00:00 EOF == EOF is false
2009/11/10 23:00:00 EOF == EOF is true

Thanks for your attention

@rjeczalik
Copy link

@RomanSaveljev You're comparing two different underlying types: https://play.golang.org/p/ZjGwVrc9ge - even if they were the same, the values are different: https://play.golang.org/p/25QG3XfQ1I. Use e.g. error codes/statuses instead.

@RomanSaveljev
Copy link
Author

Thanks for the explanation. This makes sense albeit is confusing for newcomers like me... Would it be more user-friendly, if the signature of the Call method was changed like this?

func (client *Client) Call(serviceMethod string, args interface{}, reply interface{}) ServerError

Then it would be clear the direct comparison is not suitable.

@robpike
Copy link
Contributor

robpike commented Sep 21, 2015

Because of the Go 1 compatibility guidelines, the signature cannot be changed.

@robpike robpike closed this as completed Sep 21, 2015
@golang golang locked and limited conversation to collaborators Sep 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants