-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
CLI argument to ignore paths #250
Comments
How about not using the As far as argument size limits, we could support a newline-separated list of filenames fed via a plaintext file, which is the same workaround that |
One such fixture is auto-generated go code generated by https://github.com/shurcooL/vfsgen, these absolutely must bear the Still, from a performance standpoint, ignoring Taking file path input from a (temporary) file would also work for us, that would be welcome to have. |
I'm surprised to hear code generators like vfsgen are still being used, now that Typically, if a project uses
That is what I would personally do. It does add an automated step to your
Doing it seems like a good idea in any case. If this issue moves in a different direction, then I'll split that into its own issue.
I'd rather not invent something new in this space. We do already skip |
I'm facing another issue where an excldue arg would be handy. I have to include license files in my projects and IntelliJ / Goland has the concept of file templates which will be added to Go files. They put these file templates under I agree that they should not use the file extension, but the point is that developers have to integrate with several of these usecases where it's not really up to us to chnage this. An exclude parameter in that case would come in really handy, otherwise it will fail:
I'm sure there are more legitimate usecases which would benefit from an exclude parameter. |
I actually forgot to mention, @silverwind, that generated files are treated in a special way, per the README:
The magic string is Line 117 in 3d971cb
@weeco like you point out, your case is broken by design: it's likely that many other existing Go tools, like
The only other use case mentioned here is generated files, which is already handled per the above. If Go tools in general come up with a standard in golang/go#42965, I'll be happy to follow. I'm reluctant to make up my own standard in the meantime. |
Thinking about excluding |
I wonder why you want to force naming conventions like |
BTW for generated file detection, there is a common pattern to mark them as such via foo/*.go linguist-generated There are other variants of this name as well, like |
I guess we could also teach gofumpt to look for |
See kubernetes as one example that has https://github.com/kubernetes/kubernetes/blob/master/.gitattributes |
Having configurability via |
Interesting example with kubernetes. It does seem like they're not following the Go standard, which is concerning. There doesn't seem to be a good reason, so I'm willing to bet they just didn't notice. I hear you about |
I see I never answered: |
Just to reiterate what the plan is: Go's golang/go#42965 is accepted but not yet implemented. Once it is, we will copy the strategy in gofumpt. Even though the proposal is already accepted, I'm reluctant to go ahead and implement it before they do, because that would lead to inconsistent behavior between us and upstream. |
Do the go ignores always exactly intersect with gofumpt ignores? I think not. For example consider the following use case: You have a vendored file that you want to preserve in original format for updating it later with an accurate diff preserved. Go tooling should still compile it, but you'd want it to be exempt from formatting. |
I don't find that to be a particularly strong argument. If a package would be tested via |
This kind of "one tooling fits all" mentality is why I dislike the go ecosystem. I prefer tools that are standalone and have their own configs without such dependencies like this go tooling, because ultimately this allows those tools to outgrow the narrow use cases that the go authors intend. But I guess the go community is too small to see more flexible tools come to life like for example the JavaScript/TypeScript community has. |
If you have specific use cases that wouldn't be satisfied by following golang/go#42965, I'd like to hear them and think about options. Aside from that, vague arguments against Go aren't constructive here. |
I personally don't think having random folders only needed by CI inside the |
In some cases, it's desirable to not format certain files like test fixtures. Ignoring such files can be achieved by passing a explicit list of files to gofump, but then big projects risk into running into the maximum command line length which on Windows is only 8191 characters.
I suggest to support a
-exclude
argument where users could pass individual files to exclude to the CLI. It should support both file and directory arguments. Another benefit of such a argument is to speed up the invocation by ignoring big directories likenode_modules
which often contain upwards of 100k files.go run mvdan.cc/gofumpt@v0.4.0 -exclude test/fixture.go,fixtures,node_modules .
The text was updated successfully, but these errors were encountered: