Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add generate mode and new //counterfeiter:generate directive #124

Merged
merged 5 commits into from
Jun 3, 2019

Conversation

joefitzgerald
Copy link
Collaborator

@joefitzgerald joefitzgerald commented Jun 3, 2019

This adds a //counterfeiter:generate directive and a corresponding -generate flag that can be used to look for and execute the directives.

If you are using many //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 directives in a single package, go will execute counterfeiter multiple times and cause extraneous file operations searching through all lines in each file in the package. This cost is more impactful for packages with many files and for packages with large files (as measured by line count or length of lines).

If you wish to avoid these costs, you can now have a single go:generate directive in a package:

  • //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

Then, replace instances of:

  • //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . YourInterface with:
  • //counterfeiter:generate . YourInterface

The performance gain here is relatively small, 0 <= x <= 5% on packages I tested with.

Related: #120 and #123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants