-
Notifications
You must be signed in to change notification settings - Fork 18k
errors: should have minimal dependency on reflectlite #54341
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
I also wonder if programs that depend on both |
Perhaps the reflect package can can just import reflectlite and build on top of it, instead of duplicating code. (The reflectlite package may need to export more things for reflect to use, and that is fine, as it is an internal package.) It would look nicer if the reflect package is self-contained. But probably okay if it is not. |
For "look nicer", are you referring to how the package appears in pkgsite? Implementing "reflect" in terms of "reflectlite" will probably require the primary types to be declared in |
I was mostly thinking about reading the code. It would be nicer if the code stays together. For documentation, reflectlite doesn't define many types for reflect to export, so it is probably not too bad. We probably could alias Kind and Type, or duplicate them, which shouldn't be too bad. I don't think we can alias Value as we need to define more methods on reflect.Value. reflect.Value could probably wrap reflectlite.Value. |
The issue has been settled package main
import _ "errors"
func main() {
} |
See #54341 (comment) , I think this issue can be closed. |
Closing based on previous comment. Please comment if you disagree. Thanks. |
On go1.19, A blank import of "errors" increases the binary size by ~15.5KiB due to the transitive dependency on
reflectlite
.The hard dependency occurs because of the program initialize variable for:
We could consider a trick similar to 419757
This is relevant since many packages depend on
errors
only forerrors.New
, and we should not expect those packages to forcereflectlite
to be transitively linked in.The text was updated successfully, but these errors were encountered: