-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
currently it says
// Glob ignores file system errors such as I/O errors reading directories.
// The only possible returned error is path.ErrBadPattern, reporting that
// the pattern is malformed.
but Glob now calls Stat() on pattern if pattern does not contains any of the magic characters recognized by path.Match (ie if pattern is just a file path). So any file io errors can occur (and returned).
I suspect that this change was done to allow Glob to be used in places like html/template.ParseFS which takes as arguments fs.FS and any number of glob patterns; in a way overloading it to replace both ParseGlob and ParseFiles.
I wish that ParseFS behaved more like ParseFiles (since globing is trivial to add by users if needed) or that we have both ParseGlobFS and ParseFilesFS (which IMO is cleaner: the FS versions act on fs.FS whereas the other two act on the OS filesystem). In a package I am working on, I had to copy/paste the code for template.ParseFiles into a func that takes an fs.FS because since I was processing the template files before passing them to ParseFiles, I did not need an additional Stat() call on them which would happen if I passed them to ParseFS.
Thanks,