You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Load input failed: unknown package error with aliased imports #254
Mock generation should succeed (like it does if I rename alphabetically_first.go and alphabetically_second.go to be ordered the other way around).
Additional Information
gomock mode (reflect or source): source
gomock version or git ref: v0.5.2
golang version: 1.24.0
Triage Notes for the Maintainers
There is some existing discussion about this bug in #166, but the original reported bug there was different and the issue got closed, so I'm reporting it here again with the reproduction specifically for the issue that I encountered.
Root cause: in source mode, parsePackage reads the imported package's imports from ast.MergePackageFiles(..., FilterImportDuplicates). That filter dedupes imports by path, so when one file imports a package plainly and another aliases it, the alias gets dropped and referencing it later fails with unknown package. Reading imports per-file instead of from the merged file keeps the alias. Opened #311 with the fix and a regression test.
Activity
hdimer commentedon Jul 30, 2026
Root cause: in source mode,
parsePackagereads the imported package's imports fromast.MergePackageFiles(..., FilterImportDuplicates). That filter dedupes imports by path, so when one file imports a package plainly and another aliases it, the alias gets dropped and referencing it later fails withunknown package. Reading imports per-file instead of from the merged file keeps the alias. Opened #311 with the fix and a regression test.dragonsinth commentedon Oct 15, 2026
This is a big issue when generating mocks for protos and the new grpc plugin:
x.pb.go:
x_grpc.pb.go:
mockgen now breaks reading this package.