-
Notifications
You must be signed in to change notification settings - Fork 16
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
Sucessful calls might return an error value #7
Comments
Hmmm, hold that thought, |
What I gleaned from the documentation is that:
and thats how this library behaves w.r.t errors from libc |
Yeah, but that breaks the golang way. The usual thing to do when wrapping for a language is to follow the patterns of that language, otherwise anyone using it finds it surprising, like in this case. Of course, it's your code, so you're free to decide that. Just try to add a note somewhere that it was a conscious decision. Maybe just point to this issue and close it. |
Do you have any thoughts/suggestions on how to structure the code better to avoid this confusion? |
Well, result, err := call(params)
if err != nil {
// handle error
} So just return C.GoString(c_enc), nil in line 48. |
According to the docs:
But
crypt()
does not seterrno
, and the call toC.crypt()
is building aerror
variable with a value of some other call. Iferrno
is not 0, thenerr
is notnil
. Bothhttps://github.com/amoghe/go-crypt/blob/master/crypt.go#L41
and
https://github.com/amoghe/go-crypt/blob/master/crypt.go#L48
are returning an unrelated value.
So this code might or might fail:
Like this:
The text was updated successfully, but these errors were encountered: