Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

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

Open

Description

@dominiquelefevre

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.

Activity

  1. fioncat commented on Mar 18, 2024

    @fioncat

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

  2. pgimalac commented on Dec 21, 2024

    @pgimalac

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions