Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
path/filepath: always validate full Glob patterns #28614
_, err := filepath.Match("a[", "a") // err is nil _, err := filepath.Match("a[", "abc") // err is "syntax error in pattern"
As patterns are often user input, it would be handy to be able to validate the pattern. If the validation is successful, it should be guaranteed that
I created a PR for this here and was asked to open a proposal issue first.
Other programming languages seem to either not validate the pattern at all (like Python's
@andybons I certainly like that the current implementation is as efficient as possible. I just miss the option to validate a pattern. Maybe calling
Alternatively there could be
Hi, I've been checking this issue and I would like to work on it if no one else is doing it right now as my first contribution.
I see two possible implementations using the same functions.
As per your previous conversation, you seem more inclined to the second option, right?
We want to make sure that implementation is simple, efficient, and always detects an invalid pattern. I would tend to think that the second option you list is likely to be the better approach, but I think we're open to any implementation that meets those goals as best as possible. Thanks.