golang / mock

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

Incompatibility with go modules #330

Closed dennypenta closed 4 years ago

dennypenta commented 4 years ago

With GO111MODULE=on running the following command:

mockgen -source=mypackage/ -destination=service_mocks.go -package=service_test Service

And getting an error: Loading input failed: loading package failed

I found the solution as running this one:

mockgen github.com/author/project/package > my_file.go

But I can't pass destination, package name and other options, when I'm passing it, I will give result as I executed mockgen without any parameters.

codyoss commented 4 years ago

I think the issue you are having here is providing a directory for mockgen instead of a file. Also, when using the source option you should not need to list the interface at the end.

Can you please try a command that looks something like this and let me know if that helped:

mockgen -source=service.go -destination=service_mocks.go -package=service_test
codyoss commented 4 years ago

Closing due to lack of a response. Please feel free to reopen something if you are still having trouble.