If pattern is a well-formed pattern but it does not satisfy fs.ValidPath(pattern), fs.Glob(fsys, pattern) does not return matchings and does not return errors.
For example, if fs.Glob(fsys, "a") returns []string{"a"} and nil, these other calls
fs.Glob(fsys, "/a")
fs.Glob(fsys, "a/")
fs.Glob(fsys, "./a")
return nil and nil:
I propose, before the 1.16 release, that the fs.Glob function returns the fs.ErrInvalid error if pattern is a well-formed pattern but does not satisfy fs.ValidPath instead of returning a nil matched and a nil error.
Note that the filepath.Glob function, as fs.Glob, can return only the path.ErrBadPattern error but filepath.Glob cleans the pattern before matching the files, fs.Glob doesn't.
Note also that //go:embed has the same pattern syntax of fs.Glob (except ".") but
//go:embed pattern
var files embed.FS
does not compile if pattern does not satisfy fs.ValidPath, instead of assigning to files an empty file system.
If
patternis a well-formed pattern but it does not satisfyfs.ValidPath(pattern),fs.Glob(fsys, pattern)does not return matchings and does not return errors.For example, if
fs.Glob(fsys, "a")returns[]string{"a"}andnil, these other callsreturn
nilandnil:I propose, before the 1.16 release, that the
fs.Globfunction returns thefs.ErrInvaliderror ifpatternis a well-formed pattern but does not satisfyfs.ValidPathinstead of returning anilmatched and anilerror.Note that the
filepath.Globfunction, asfs.Glob, can return only thepath.ErrBadPatternerror butfilepath.Globcleans the pattern before matching the files,fs.Globdoesn't.Note also that
//go:embedhas the same pattern syntax offs.Glob(except ".") butdoes not compile if
patterndoes not satisfyfs.ValidPath, instead of assigning tofilesan empty file system.