-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: reflect: add Type.IsEmptyInterface #41896
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
Comments
See discussion in #41882. |
A few thoughts:
|
Change https://golang.org/cl/263078 mentions this issue: |
See also #42099. |
We are probably going to roll back that change - see #42123 - so it looks like we don't need this. |
I still think we should add this method, to provide a better/correct way for user to detect empty interface. |
It's certainly easy to go overboard on helpers. |
Since we rolled back that change, this seems like a likely decline. |
No change in consensus, so declined. |
Coming from #41882, @ianlancetaylor suggests adding:
to
reflect
package to detect empty interface.Currently, users (including standard libraries, Google internal code, are relying on
reflect.Type.NumMethod() == 0
to check empty interface, which is wrong. After #22075 is fixed, code which uses wrong behavior should be changed to:Adding
reflect.IsEmptyInterface
will help user's migration easier.The text was updated successfully, but these errors were encountered: