Closed powerman closed 4 years ago
@powerman is this that modules might have solved?
Nope, nothing changed, issue still actual in current master.
I also have the same problem, and use -self_package
parameter to solve temporarily.
Thanks, I will look more into this.
Sorry I slipped on following up on this. I will check it out soon.
So there are four test cases here. Here are my thoughts on each.
Example commands run. Each run with the file contents you provided. Also, the folder is a module example.com/gm310
. Also also, I have gomock built off master which does have some more fixes in it around self_package
:
mockgen -package gm310 -self_package=example.com/gm310 -source=/home/codesworth/scratch/gm310/gm310.go -destination=/home/codesworth/scratch/gm310/gm310_mock.go
mockgen -package gm310 -self_package=example.com/gm310 -destination=/home/codesworth/scratch/gm310/gm310_mock.go example.com/gm310 App
Closing this issue as the only real problem here is the alias stuff, which is being handled as another issue. Thanks.
@codyoss I'm not sure I get it. I've reported issue when running without -self_package
. You've tested with -self_package
and closed the issue. What's the point? Is it means running without -self_package
is not supported/recommended outside of GOPATH? Why don't set default value for -self_package
?
Sorry you are right, I did get a little mixed up here. I still do think the only real issue is the first case though. I also agree it would be great if self_package
was not needed, but right now it is. That is why it does exist. I do have plans in the future to obsolete this flag, but for now it is around for a reason.
Both source and reflect mode fail in different cases outside of GOPATH. One case is type aliases (already mentioned in #144 and #244), another is using type defined in same package. Inside GOPATH all cases works (both with and without
-self_package
). Outside GOPATH all cases works only with-self_package
. Here is test case and matrix of working/broken cases when used outside GOPATH without-self_package
:Full example available in https://github.com/powerman/bug-gomock
Maybe it makes sense to set default value for
-self_package
as a workaround to make it work everywhere out of box?