Idea: Glob-based include/exclude configuration
Air currently supports 6 config options to include/exclude files:
include_ext = ["go", "tpl", "tmpl", "html"]
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
include_dir = []
include_file = []
exclude_file = []
exclude_regex = ["_test\\.go"]
I think from a user perspective, these options are hard to understand and I suggest to additionally support a glob-based configuration with include and exclude options. exclude should take precedence. Above could be rewritten as:
include = [
"**/*.{go,tpl,tmpl,html}",
]
exclude = [
"./{assets,tmp,vendor}",
"./frontend/node_modules",
"**/*_test.go",
]
Currently, I'm considering this feature because the current air options are a little bit confusing to the users
If you are willing to do a breaking change (v2), I'd suggest making the glob-based include and exclude options the only options and remove all the others.
Yes, I plan to keep other options until the next v2 breaking change
I want to know if the glob-based configuration can unify different OS configurations. I don't want users to have to consider OS differences.
Make the patterns accept forward slashes only and when on Windows, replace foward with backward slashes. That's how pretty much all glob implementations that I know work.
I'm not sure which package is the premier glob package nowadays in golang, it was https://github.com/gobwas/glob at one point, but that one seems to have gone out of maintenance.
Yes, we need to find a reliable package in Go.
gobwas/glob is definitely not right, it's a pattern matching library, not a file system glob library. I just noticed how misnamed it actually is.
I think stdlib https://pkg.go.dev/path/filepath#Glob might be good. The only thing that seems to be missing (compared to other implementations) is to specify exclude patterns, so exclusion patterns need to be applied in a post-processing step, which will hurt theoretical performance.
You might also consider the https://github.com/bmatcuk/doublestar. It supports a range of extended globbing patterns, including exclusion rules, recursive directory matching, and more. It’s also used in arelo, so it has some proven usage in similar tools.
Let me try https://github.com/bmatcuk/doublestar and https://pkg.go.dev/path/filepath#Glob. By the way, please do not advertise in the issue. If I reference your code, I will include your repository in the README credit section.