fs

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package fs contains an HTTP file system that works with zip contents.

Index

Constants

This section is empty.

Variables

View Source
var SkipDir = errors.New("skip dir")

Functions

func New

func New() (http.FileSystem, error)

New creates a new file system with the registered zip contents data. It unzips all files and stores them in an in-memory map.

func ReadFile added in v0.1.2

func ReadFile(hfs http.FileSystem, name string) ([]byte, error)

ReadFile reads the contents of the file of hfs specified by name. Just as ioutil.ReadFile does.

func Register

func Register(data string)

Register registers zip contents data, later used to initialize the statik file system.

func Walk added in v0.1.2

func Walk(hfs http.FileSystem, root string, walkFn WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn.

Types

type WalkFunc added in v0.1.2

type WalkFunc func(path string, info os.FileInfo, err error) error
WalkFunc is the type of the function called for each file or directory visited by Walk.

The path argument contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", the walk function will be called with argument "dir/a". The info argument is the os.FileInfo for the named path.

If there was a problem walking to the file or directory named by path, the incoming error will describe the problem and the function can decide how to handle that error (and Walk will not descend into that directory). If an error is returned, processing stops. The sole exception is when the function returns the special value SkipDir. If the function returns SkipDir when invoked on a directory, Walk skips the directory's contents entirely. If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory.

Jump to

Keyboard shortcuts

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