Documentation

Overview

    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.
    

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Keep

    func Keep(source http.FileSystem, keep Func) http.FileSystem

      Keep returns a filesystem that contains only those entries in source for which keep returns true.

      Example
      Output:
      
      

      func Skip

      func Skip(source http.FileSystem, skip Func) http.FileSystem

        Skip returns a filesystem that contains everything in source, except entries for which skip returns true.

        Example
        Output:
        
        

        Types

        type Func

        type Func func(path string, fi os.FileInfo) bool

          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

          func FilesWithExtensions(exts ...string) Func

            FilesWithExtensions returns a filter func that selects files (but not directories) that have any of the given extensions. For example:

            filter.FilesWithExtensions(".go", ".html")
            

            Would select both .go and .html files. It would not select any directories.