Package filter offers an http.FileSystem wrapper with the ability to keep or skip files.
Example (Detailed) ¶
Output: / /a-file.txt /another-file.txt /folder-to-skip /folderA /folderA/entry-A.txt /folderA/entry-B.txt /zzz-last-file.txt os.IsNotExist(err): true open /folderA/main.go: file does not exist os.IsNotExist(err): true open /folderA/folder-to-skip: file does not exist This is a file, not a folder, and shouldn't be skipped.
Keep returns a filesystem that contains only those entries in source for which keep returns true.
Func is a selection function which is provided two arguments, its '/'-separated cleaned rooted absolute path (i.e., it always begins with "/"), and the os.FileInfo of the considered file.
The path is cleaned via pathpkg.Clean("/" + path).
For example, if the considered file is named "a" and it's inside a directory "dir", then the value of path will be "/dir/a".
func FilesWithExtensions ¶
FilesWithExtensions returns a filter func that selects files (but not directories) that have any of the given extensions. For example:
Would select both .go and .html files. It would not select any directories.