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

check for nil interfaces #251

Merged
merged 3 commits into from
Jul 17, 2024
Merged

check for nil interfaces #251

merged 3 commits into from
Jul 17, 2024

Conversation

MarcoPolo
Copy link
Contributor

This continues the work in #250 by adding some checks to ensure we don't call interface methods on a nil interface.

You could argue that the caller should always make sure not to pass in a nil interface. I don't disagree, I think that is still best practice. But this check is cheap, we can handle it in a reasonable way, and it prevents a runtime panic. Panics should be reserved for "I have no idea what I should do next, it's best to crash". We know what is reasonable to do here, so no need to crash.

@MarcoPolo MarcoPolo requested a review from sukunrt July 16, 2024 20:18
@sukunrt sukunrt merged commit bbdd1a5 into master Jul 17, 2024
9 checks passed
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.

2 participants