-
Notifications
You must be signed in to change notification settings - Fork 32
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
using GetDefinitionForFilename incrementally #30
Comments
If this sounds like a good idea and noone plans to work on it, I might send a patch myself. |
Here's a draft of what the API could look like:
|
Hi @mvdan, This suggestion is totally reasonable. My counter-proposal on the API would be something like: type Finder {
// unexported fields only
}
func New(r io.Reader) (*Finder, error) {
// ...
}
func (*Finder) Find(filename string) (*EditorConfig, error) {
// ...
} |
I don't think that API would cut it; it's constrained to a single |
Closing this since you're making your own library for this anyway. I don't think we'll have that soon in this one. |
Thanks for this library! I'm looking at using it to implement mvdan/sh#393.
Here's one problem, though. When one runs a command like
shfmt -l -w .
, it searches all shell files under the current directory, similar to whatgofmt
would do.Imagine a fairly simple use case, where we have a few hundred shell files and an
.editorconfig
in the current directory. As I read the source forGetDefinitionForFilename
, I'm a bit horrified, as using it for each of the shell script paths would result in the library re-reading and re-parsing the editorconfig hundreds of times.I think the library should expose a stateful, incremental API. Keeping data in a struct, and using methods, it could cache:
For my sample use case above, this would mean only parsing the editorconfig once, and also only one stat call per directory containing a shell script.
For the sake of simplicity, merging of editorconfig files doesn't need to be cached.
The text was updated successfully, but these errors were encountered: