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

Read: always return nil slice on error #47

Closed
wants to merge 1 commit into from
Closed

Read: always return nil slice on error #47

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 4, 2018

This lets one more easily distinguish between a key that doesn't exist and an existing key with an empty value.

@peterbourgon
Copy link
Owner

I don't quite understand the rationale here, and I don't understand the "fix". If a key doesn't exist, Read will return a non-nil error. If a key exists with an empty value, Read will (should?) return a nil error.

Additionally, by convention, if any function returns non-nil error, the other return values should be considered undefined. Doing any comparison on return values in the presence of a non-nil error is probably incorrect, and so I'm hesitant there, too.

@ghost
Copy link
Author

ghost commented Sep 4, 2018

I want to be able to perform one comparison, not two.

Additionally, by convention, if any function returns non-nil error, the other return values should be considered undefined.

I doubt it. AFAIK all the stdlib functions return zero value in case of an error, except some readers where partial content could be useful. But okay, feel free to close this PR, I'll just use my fork then.

@peterbourgon
Copy link
Owner

Additionally, by convention, if any function returns non-nil error, the other return values should be considered undefined.

I doubt it.

(shrug) It's idiomatic. Phrased another way,

[We should] give no guarantee whatsoever of the state of the other return values in the presence of an error.

https://groups.google.com/d/msg/golang-nuts/lcZNt-nMsl0/rIzW91kICAAJ


I'll just use my fork then.

👍

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

Successfully merging this pull request may close these issues.

None yet

1 participant