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

Remove the dependency on github.com/modern-go/reflect2 #691

Open
dominiquelefevre opened this issue Jan 3, 2024 · 2 comments
Open

Remove the dependency on github.com/modern-go/reflect2 #691

dominiquelefevre opened this issue Jan 3, 2024 · 2 comments

Comments

@dominiquelefevre
Copy link

dominiquelefevre commented Jan 3, 2024

reflect2 is too brittle because of the reliance on the internals of the golang's compiler. Moreover, it is no longer maintained: github.com/modern-go/reflect2..

Replace the usages of github.com/modern-go/reflect2 with stdlib's reflect.

@fioncat
Copy link

fioncat commented Mar 18, 2024

Agreed, after i updated go to 1.20, reflect2 panic directly, this is awful.

@pgimalac
Copy link

pgimalac commented Dec 21, 2024

Also for the record reflect2 wraps reflect.Type under the hood, which means when using it the linker considers the Method and MethodByName functions as reachable (even if this library doesn't use them), which disables some dead code elimination, resulting in a significantly bigger binary... (see this talk for more details)

Having this optimization enabled reduced a binary I work on from around 36MB to 29MB.

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

No branches or pull requests

3 participants