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

Must* methods are inconsistent with the standard library. #15

Open
bmatsuo1 opened this issue Apr 13, 2013 · 1 comment
Open

Must* methods are inconsistent with the standard library. #15

bmatsuo1 opened this issue Apr 13, 2013 · 1 comment

Comments

@bmatsuo1
Copy link

I find the Must* methods to be fairly misleading. In the standard library a Must prefix implies that when the underlying function/method returns an error a runtime panic will be occur. It wasn't until reading the source code that I realized this was not the case. I would like to propose two things:

  • State in the documentation that when the underlying method returns an error that the return value will be the zero value for that type (or the default value).
  • In the next major version, rename this methods to avoid confusion. After thinking of alternatives I think the prefix Just would be more appropriate.
@mostafah
Copy link

That’s a valid point.

But the ideal, IMHO, would be to have Int only return one int value, and have another function, say, CheckInt, that returns an error too.

Also, shouldn’t the error be the first return parameter?

gabriel-alecu pushed a commit to gabriel-alecu/go-simplejson that referenced this issue Jul 17, 2014
- Added "Check" prefix to the ones that also return an error.
- Removed the "Must" prefix from those that always return a valid value.

fixes issue bitly#15
gabriel-alecu pushed a commit to gabriel-alecu/go-simplejson that referenced this issue Jul 17, 2014
- Added "Check" prefix to the ones that also return an error.
- Removed the "Must" prefix from those that always return a valid value.

fixes issue bitly#15
xyproto pushed a commit to xyproto/jpath that referenced this issue Jun 16, 2015
- Added "Check" prefix to the ones that also return an error.
- Removed the "Must" prefix from those that always return a valid value.

fixes issue bitly#15
jacoduplessis added a commit to jacoduplessis/simplejson that referenced this issue May 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants