go-simplejson
go-simplejson copied to clipboard
Must* methods are inconsistent with the standard library.
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
Justwould be more appropriate.
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?