-
Notifications
You must be signed in to change notification settings - Fork 24
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 support for Go standard use of ./... #51
Add support for Go standard use of ./... #51
Conversation
Refactor to enable using the ./... syntax to recursively process a directory. This changes the behaviour of the program as before the analysis was always recursive unless the "-n" was used. Because the analysis is now only recursive when a path ends in ... the "-n" flag is no longer necessary. So this changes the program in two breaking ways: - "-n" is no longer useful. - Old paths that would be analyzed recursively will no longer be analyzed recursively.
As the "-n" flag is no longer needed with support for the "./..." syntax. Instead of removing it I marked it as "[DEPCRECATED]", this prevents the program from exiting with an error when it is used.
Thanks for the PR. Ideally, I think this feature would come from using golang.org/x/tools/go/analysis (or at least golang.org/x/tools/go/packages). If you're willing to rework this change to use one of those packages, that would be great. If not, I totally understand – just say so and I'll merge this as-is. |
I'm afraid both of those would require more refactoring than I'm comfortable with. If I'm mistaken, then if you could give me some indication of where/how to get started I'm willing to give it a try 🙂 |
I don't know what you're comfortable with so you'll have to tell me :) I think it should be as simple as:
Of course, nothing ends up being quite as simple as one expects! |
For backwards compatibility
Thanks for that, that was enough for me to do it - I think. The changes in the PR are now a bit more substantial, but ultimately the amount of code was reduced quite a bit. I'm not 100% everything works as one would expect, but from my manual tests it works as I would expect. Let me know if anything is missing or anything in the code should be changed. The only problem I wasn't quite able to figure out myself was the automated tests... I attempted to use analysis/analsysistest but that doesn't play nicely with the testdata in this repo. It seems that it doesn't work because the testdata has compilation problems, but I'm not sure how to resolve this. If you want @gordonklaus, feel free to push changes for that directly to this branch. Also, the help messages changed significantly due to the usage of the analyzer. I'm not sure what you think about it, it seems that most flags work out the box. But, regarding #53, the
|
Nice work! I pushed some changes to your branch, including making the automated tests work and restoring the ignoring of generated files (which was lost with your changes). I think we can worry about the It sounds like you're happy with the changes, but anyway let me know if that's still the case and I'll merge it. |
Awesome, thanks for the help! I made a small adjustment to 7c2182d to make the code a tiny bit easier to read (if you don't like it, feel free to revert that change).
Oops, forgot to test that 😅 Thanks for adding it back! It's a shame that dmitri.shuralyov.com/go/generated doesn't support |
Nice!
Perhaps. I created golang/go#43481 to find out. |
This adds support for Go standard use of
./...
to recursively analyze a directory.Note that this breaks current usage in two ways:
-n
flag is used. After this change such invocations will be non-recursive unless the "/..." suffix is added.-n
flag is deprecated as it is no longer meaningful with./...
support. I deprecated it instead of removing it because if the flag is used when not registered the program exits with an error before doing anything.