golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.26k stars 608 forks source link

Source mode fails with embedded interfaces in the same package #638

Closed joy717 closed 2 years ago

joy717 commented 2 years ago

this issue is the same with https://github.com/golang/mock/issues/178 the sourceFile and the EmbededFile are in the same package but are different files.

even use this command, still got an error:

mockgen -source test2.go -destination test2_mocks.go -package test -aux_files=github.com/anyuser/test=test1.go

I know there is another issue: https://github.com/golang/mock/issues/85 but #85 is two files in two packages.

gomock version: 1.6.0

joy717 commented 2 years ago

It's worked great. That's my fault. I'm using go module. the package name in -aux_files was misconfigured

joy717 commented 1 year ago

It's worked great. It was the wrong package name that caused the problem.

On Tue, Jul 26, 2022 at 6:31 PM Yuu177 @.***> wrote:

I have the same problem, how did you solve it?

— Reply to this email directly, view it on GitHub https://github.com/golang/mock/issues/638#issuecomment-1195305429, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACLYDDNVEWZIUVXJN2Z5NDVV646LANCNFSM5UKTUQDQ . You are receiving this because you modified the open/close state.Message ID: @.***>

caiqiyong commented 1 year ago

hey, I got the same problem, the command below still not work, how did you solve the problem?

mockgen -source test2.go -destination test2_mocks.go -package test -aux_files=github.com/anyuser/test=test1.go

what did you mean misconfigure package name?

joy717 commented 1 year ago

hey, I got the same problem, the command below still not work, how did you solve the problem?

mockgen -source test2.go -destination test2_mocks.go -package test -aux_files=github.com/anyuser/test=test1.go

what did you mean misconfigure package name?

I worte a wrong package name.

-aux_files $PACKAGE_NAME=$REAL_LOCATION_OF_FILE

the $REAL_LOCATION_OF_FILE is based on the path of mocken xxxx command executed.

for example: if I executed mockgen -source test2.go ... in the location github.com/anyuser/, -aux_files github.com/anyuser/test=../test1.go

but if I exected mockgen -source test2.go ... in the location github.com/anyuser/test/, then -aux_files github.com/anyuser/test=test1.go