Documentation ¶
Overview ¶
Package fsutil provides useful utility functions for http.FileSystem.
Index ¶
- func Glob(fs http.FileSystem, patterns ...string) (http.FileSystem, error)
- func TmplParse(fs http.FileSystem, tmpl *txttmpl.Template, paths ...string) (*txttmpl.Template, error)
- func TmplParseGlob(fs http.FileSystem, tmpl *txttmpl.Template, pattern string) (*txttmpl.Template, error)
- func TmplParseGlobHTML(fs http.FileSystem, tmpl *htmltmpl.Template, pattern string) (*htmltmpl.Template, error)
- func TmplParseHTML(fs http.FileSystem, tmpl *htmltmpl.Template, paths ...string) (*htmltmpl.Template, error)
- func Walk(hfs http.FileSystem, root string) *fs.Walker
- type FileSystemDiff
- type PathDiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Glob ¶ added in v0.1.0
func Glob(fs http.FileSystem, patterns ...string) (http.FileSystem, error)
Glob return a filesystem that contain only files that match any of the provided patterns. If no patterns are provided, the original filesystem will be returned. An error will be returned if one of the patterns is invalid.
func TmplParse ¶
func TmplParse(fs http.FileSystem, tmpl *txttmpl.Template, paths ...string) (*txttmpl.Template, error)
TmplParse parses templates from the given filesystem according to the given paths. If tmpl is not nil, the templates will be added to it. paths must contain at least one path. All paths must exist in the given filesystem.
func TmplParseGlob ¶
func TmplParseGlob(fs http.FileSystem, tmpl *txttmpl.Template, pattern string) (*txttmpl.Template, error)
TmplParseGlob parses templates from the given filesystem according to the provided glob pattern. If tmpl is not nil, the templates will be added to it.
func TmplParseGlobHTML ¶
func TmplParseGlobHTML(fs http.FileSystem, tmpl *htmltmpl.Template, pattern string) (*htmltmpl.Template, error)
TmplParseGlobHTML parses HTML templates from the given filesystem according to the provided glob pattern. If tmpl is not nil, the templates will be added to it.
func TmplParseHTML ¶
func TmplParseHTML(fs http.FileSystem, tmpl *htmltmpl.Template, paths ...string) (*htmltmpl.Template, error)
TmplParseHTML parses HTML templates from the given filesystem according to the given paths. If tmpl is not nil, the templates will be added to it. paths must contain at least one path. All paths must exist in the given filesystem.
func Walk ¶
func Walk(hfs http.FileSystem, root string) *fs.Walker
Walk returns a fs.Walker over http.FileSystem, which enables walking over all files in the filesystem.
See https://godoc.org/github.com/kr/fs#Walker for more details.
Types ¶
type FileSystemDiff ¶ added in v0.1.0
FileSystemDiff lists all differences between two filesystems.
func Diff ¶ added in v0.1.0
func Diff(a, b http.FileSystem) (*FileSystemDiff, error)
Diff returns the difference in filesystem structure and file content between two filesystems. If the implementation of the filesystem is different but the structure and content are equal, the function will consider the object as equal. For equal filesystems, an empty slice will be returned. The returned differences are ordered by file path.
func (*FileSystemDiff) String ¶ added in v0.1.0
func (d *FileSystemDiff) String() string
String returns pretty representation of a filesystem diff.