Closed omarkohl closed 4 years ago
The problem goes away if I replace the go:generate command and remove the explicit package.
not:
//go:generate moq -pkg moqproblem -out corrupted_file_getter_moq.go . CorruptedFileGetter
instead:
//go:generate moq -out corrupted_file_getter_moq.go . CorruptedFileGetter
But I still think it is a bug. Why shouldn't it be possible to explicitly state the package even if it is the same as the one where the interface is defined?
The -pkg
flag is meant to be used when the destination package is different (ex: moqproblem_test
in the same folder or mocks
in a completely different folder by also specifying -out ../mocks/corrupted_file_getter_moq.go
).
Since updating moq a few hours ago we are getting import cycles when re-generating the mocks. I strongly suspect this is due to #62. The line marked with a comment "NEW and causes problems" was not inserted by moq until now.
File: api/usecase/moqproblem/usecase.go
File: api/usecase/moqproblem/corrupted_file_getter_moq.go
EDIT: Update the example to be executable. Try it out:
You will get the following error: