io/fs: wrong comment about func Glob(fsys FS, pattern string) #44252
Labels
Documentation
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
currently it says
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,
The text was updated successfully, but these errors were encountered: