Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Use of -aux_files causes incorrect generated code in case of embedded interface with package name overlap #691

@GillesMoris-NexuzHealth

Description

@GillesMoris-NexuzHealth

Actual behavior Using -aux_files when generating a mock for an interface with an embedded interface, combined with overlapping package names and a resulting named import can cause the generated code to use the wrong package name for parameters of the nested interface. Generating without the -aux_files flag does not have the same issue.

Expected behavior No errors in generated code when using -aux_files.

To Reproduce Steps to reproduce the behavior

mockgen_issue.zip
The attached zip contains a minimal reproduction case that is somewhat modeled after how it occurred in our codebase, running the mockgen command in foo.go will generate an invalid mock.

Additional Information

  • gomock mode (reflect or source): source
  • gomock version or git ref: v1.6.0
  • golang version: 1.18

Can be worked around by not using -aux_files or by turning the overlapping package name import into a differently named import as well.

Triage Notes for the Maintainers
Issue regarding -aux_files, which we were using but after retrying without it seems like we might not need it anymore, but as long as it's not deprecated it should still result in correct mock generation.

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