fsutil

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package fsutil provides useful utility functions for http.FileSystem.

Index

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

type FileSystemDiff struct {
	Diffs []PathDiff
	// FileSystem names.
	A, B string
}

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.

type PathDiff added in v0.1.0

type PathDiff struct {
	Path     string
	Diff     string
	DiffInfo string
}

PathDiff is a diff between two filesystems at a single path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL