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

use value instead of pointer where possible #594

Open
tharvik opened this issue Oct 30, 2019 · 1 comment
Open

use value instead of pointer where possible #594

tharvik opened this issue Oct 30, 2019 · 1 comment

Comments

@tharvik
Copy link
Contributor

tharvik commented Oct 30, 2019

There is many method defined with ptr receiver but which will fail when called with a nil. Also, many function takes a ptr to a value but doesn't handle the nil case. Even many struct contains list of non-nil pointers, ptr field which has to be defined, ...

For example, let's take Roster. NewRoster can return nil (instead of an error), but then, none of its methods will work. It contains a []*network.ServerIdentity, but all methods using it simply dereference each element. All its methods are ptr receiver but most (all maybe) doesn't mutate anything. Most methods return ptr but returning nil doesn't makes sense (or is used as an error channel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants