golang / mock

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

Mockgen : Imports doesn't generate import line #620

Closed marcelloh closed 2 years ago

marcelloh commented 2 years ago

When I add an import flag to the generate like this -imports repository=github.com/company/framework/middleware/repository I expect the line to be added as an import in the generated mock

To Reproduce Steps to reproduce the behavior

//go:generate mockgen -destination=./mocks/mock-repo.go -self_package=github.com/company/customer/vendor/github.com/company/framework/middleware/repository -package=mocks -source=../vendor/github.com/company/framework/middleware/repository/repository.go -imports repository=github.com/company/framework/middleware/repository

Additional Information

Triage Notes for the Maintainers

codyoss commented 2 years ago

Hey, sorry for the slow rely, can yo please share some code to reproduce this?

MarcelXia commented 2 years ago

I'm sorry, I have to dig deep. 2 .5 months ago, that's like 2 human years :-(

I think it is like this: we have a company library with an interface. This all exists inside a vendor folder. But I want the mock file to be generated inside the customers project where we use that. I added the imports flag to the line so I expect that import to be part of the generated file, but it isn't.

codyoss commented 2 years ago

Without seeing an example this will be hard for me to reproduce. I am closing this for now but feel free to reopen if you can provide an example.

junmaqiang commented 1 year ago

The following sentence is invalid

-imports repository=github.com/company/framework/middleware/repository