matryer / moq

Interface mocking tool for go generate
http://bit.ly/meetmoq
MIT License
2k stars 127 forks source link

Don't add Mock suffix when a destination package contains mock #148

Closed cristaloleg closed 10 months ago

cristaloleg commented 3 years ago

Hi, thank you for the lib, it's really awesome.

I've a case like that:

//go:generate moq -pkg mock -out ../mock/answer_store_mock.go . AnswerStore:AnswerStore
type AnswerStore interface {
    // etc
}

as you can see I'm typing AnswerStore 2 times to get rid of Mock suffix (it will be AnswerStoreMock as you can guess). But this doesn't make sense 'cause destination package will be mock, for me mock.AnswerStoreMock contains too much mock in the name :)

Is it possible to add a flag with defines exact final name (-name?) or there will be a feature to not append Mock at the end when pkg is mock (or contains mock). Latest probably will break backward compatibility :(

Thanks.

sudo-suhas commented 3 years ago

While I agree that having to repeat the name ideally should not have been necessary, it does not seem feasible to solve this without breaking backwards compatibility. And in this case, the cost of breaking existing usages does not seem worth the cosmetic benefit.

cristaloleg commented 10 months ago

🤷