Skip to content

Support overriding destination package name and type naming template in "-generate" call #191

Open
@matt-royal

Description

I've found that I prefer to use a package called "fake" for my fakes, and that I prefer to remove "Fake" from the type name. This looks like the following currently:

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate -o fake -fake-name MyRepository . MyRepository
//counterfeiter:generate -o fake -fake-name MyPresenter . MyPresenter

This allows me to refer to the fake like this:

myRepository := new(fake.MyRepository)

Unfortunately, I have to repeat those -o and -fake-name arguments in every generate call. It would be nice to be able to do something like the following:

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate -o fake -fake-name-template "{{.TargetName}}"
//counterfeiter:generate . MyRepository
//counterfeiter:generate . MyPresenter

I'm happy to work on a PR to add this behavior, but I want to make sure you'd be open to the idea first. I'd also love to hear other ideas to accomplish the same goal of removing repetition and risk of inconsistency.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions