-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: import and arg collision (#219)
This PR fixes an issue where if the name of an argument to a method that is being mocked collides with the name of a package that needs to be imported, mockgen could generate uncompilable code. Resolves #218
- Loading branch information
1 parent
c205527
commit eb67641
Showing
5 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
mockgen/internal/tests/import_collision/internalpackage/foo.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package internalpackage | ||
|
||
type FooExported struct{} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package p2 | ||
|
||
//go:generate mockgen -destination=mocks/mocks.go -package=internalpackage . Mything | ||
|
||
import ( | ||
"go.uber.org/mock/mockgen/internal/tests/import_collision/internalpackage" | ||
) | ||
|
||
type Mything interface { | ||
// issue here, is that the variable has the same name as an imported package. | ||
DoThat(internalpackage int) internalpackage.FooExported | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters