-
Notifications
You must be signed in to change notification settings - Fork 93
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
separate go:generate logic from counterfeiter:generate logic #170
separate go:generate logic from counterfeiter:generate logic #170
Conversation
@rittneje thanks so much for your contribution! 🙏🙏🙏 The current behavior was introduced to counteract the large regression (1-2 orders of magnitude) in speed associated with the use of It's clear that there is an issue with the regular expression being used to identify I am torn here on what to do:
I am sympathetic to the argument that we should use the |
@joefitzgerald I don't understand how the existing logic helps people who are using the classic |
The way it is implemented, only the first counterfeiter/command/runner.go Line 80 in eb18930
Said another way: Using The caching we can do when we intercept this delivers workflow enhancements that in some projects is measured in minutes per |
@joefitzgerald I see. I was confused by that logic, but I understand now what it does. Basically, only the first That being said, the current logic violates both its own documentation and the documentation of bar.go //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 os.FileInfo foo.go //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 io.Reader If I run So the only way to preserve the proper behavior of this tool is to generate all and only what was explicitly requested in the original command. The teams that need the performance enhancement need to use your If you are concerned about people not knowing about the |
Yes, I see your point. Perhaps I could switch the file scanning on invocation by go generate to emit a warning when multiple go:generate directives exist in a single package. The warning would advise them to use the |
Is it worth checking for multiple invocations? If the intent is to deprecate the classic To suppress the warning, I'm thinking an environment variable would be the best approach, so that the users in question don't have to go modify a ton of |
@joefitzgerald I wanted to follow up on this. The version of counterfeiter we've been stuck on seems to be incompatible with Go 1.15, so we are between a rock and a hard place. |
Thanks for your patience @rittneje this is now released: https://github.com/maxbrunsfeld/counterfeiter/releases/tag/v6.4.0 . |
Fixes #166.
@joefitzgerald According to the usage message from counterfeiter, the
-generate
flag is supposed to cause it to evaluate all and only the//counterfeiter:generate
directives in the current package.Consequently, the existing behavior of trying to also include
//go:generate counterfeiter
directives in the same bulk request is counter to the documented behavior. Additionally, running counterfeiter without the-generate
flag should not trigger any such bulk request logic (the legacy behavior).As such, I have untangled the legacy logic from the
-generate
logic, which simplifies things greatly. In short:-generate
flag was passed, collect all//countefeiter:generate
directives, and execute them.