-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🔥 feat(utils): add IsZeroValue #2760
Conversation
basic types based on https://go.dev/tour/basics/11 |
@sixcolors Probably worth comparing your implementation with this one: https://github.com/duke-git/lancet/blob/main/validator/validator.go#L390 Unit-Tests here: https://github.com/duke-git/lancet/blob/main/validator/validator_test.go#L413 Lancet is used by over +1k repos, so it's worth comparing. |
Set to draft while considering if related change is appropriate or not |
As @nickajacks1 pointed out #2751 (comment) a IsZeroValue check for ContextKeys would cause issues for some types that could be valid keys. So I’m closing this PR. |
Description
Add utils function to support change to #2751
Adds IsZeroValue function to utils pkg. Which reports whether x is the zero value for its type. For basic types and error, it uses a fast path without reflection. For other types, it uses reflection which is slower.
Type of change
Please delete options that are not relevant.
Checklist: