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

Avoid stringer-related deadlocks without adding ISGOMOCK #204

Merged
merged 1 commit into from
Sep 18, 2024

Commits on Sep 18, 2024

  1. Avoid stringer-related deadlocks without adding ISGOMOCK

    A deadlock related to controller calling Stringer on mocks themselves
    was revealed in uber-go#116. uber-go#144 solved this deadlock by adding a generated
    `ISGOMOCK()` method to all generated mocks, and then checking for it
    before calling `.String()` on arguments.
    
    This reveals an exported method on each generated mock that:
    * Bloats the generated code
    * Can be taken dependency on in strange ways via Hyrum's Law
    * Technically opens up another route for naming collision.
    
    This PR attempts to clean up this type of check by instead generating
    an unexported field in generated mock structs instead, and checks for it using reflect.
    This hides this implementation detail of gomock/mockgen better,
    and produces less generated bloat.
    
    Note that, importantly, the regression test added in uber-go#144 still passes
    with this PR.
    
    Ref: uber-go#193
    JacobOaks committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    1f58549 View commit details
    Browse the repository at this point in the history