walker

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadFileWalker

type ReadFileWalker interface {
	ReadFile(string) ([]byte, error)
	Walk(string, filepath.WalkFunc) error
}

ReadFileWalker is used to walk a file tree and read the contents of each file This is used for mocking. `afero.Afero` fulfills this interface. `filepath.Walk` and `ioutil.ReadFile` are functions in the core packages that fit these signatures.

type ResourceDir

type ResourceDir struct {
	// Base is the base (root) dir that will be walked. It is expected to be an absolute path,
	// i.e. have a root to the path, at the very least "/".
	Base   string
	Walker ReadFileWalker
	// contains filtered or unexported fields
}

ResourceDir contains the the directory to walk on and the WalkFuncs to perform

func (*ResourceDir) AddStep

func (rd *ResourceDir) AddStep(pattern string, step Step)

AddStep adds a Step to the Walker Each Step will be given the bytes and filepath of resource files matching the supplied name pattern

func (*ResourceDir) Walk

func (rd *ResourceDir) Walk() error

Walk applies all of the Step functions against the Base directory

type ResourceWalker

type ResourceWalker interface {
	Walk() error
	AddStep(pattern string, step Step)
}

ResourceWalker builds a Step list with the intent to Walk them

type Step

type Step func(path string, bytes []byte) error

A Step is a function that takes the name and bytes of a file and processes it in some way

Jump to

Keyboard shortcuts

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