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

MustLoadFromContext now panics if the key is not present #52

Merged
merged 2 commits into from
Aug 7, 2022

Conversation

ccremer
Copy link
Owner

@ccremer ccremer commented Aug 7, 2022

Summary

This actually conforms to the usual "must" convention.
Besides, returning nil if a key is not found only hides the root cause when troubleshooting
nil pointer panics.

Users that depend on previous behaviour (returning nil or default value) can now use new function LoadFromContextOrDefault and pass a default value that is returned in case of inexisting key.

Checklist

  • Categorize the PR by setting a good title and adding one of the labels:
    fix, enhancement, documentation, change, breaking, dependency
    as they show up in the changelog
  • Update documentation.
  • Update tests.

This actually conforms to the usual "must" convention.
Besides, returning nil if a key is not found only hides the root cause when troubleshooting
nil pointer panics.
@ccremer ccremer merged commit 0278dc8 into master Aug 7, 2022
@ccremer ccremer deleted the must-load-context branch August 7, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant