walker

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkipNode = errors.New("skip this node")

ErrSkipNode is returned by WalkFunc when a dir node should not be walked.

Functions

func Walk

func Walk(ctx context.Context, repo restic.TreeLoader, root restic.ID, ignoreTrees restic.IDSet, walkFn WalkFunc) error

Walk calls walkFn recursively for each node in root. If walkFn returns an error, it is passed up the call stack. The trees in ignoreTrees are not walked. If walkFn ignores trees, these are added to the set.

Types

type WalkFunc

type WalkFunc func(parentTreeID restic.ID, path string, node *restic.Node, nodeErr error) (ignore bool, err error)

WalkFunc is the type of the function called for each node visited by Walk. Path is the slash-separated path from the root node. If there was a problem loading a node, err is set to a non-nil error. WalkFunc can chose to ignore it by returning nil.

When the special value ErrSkipNode is returned and node is a dir node, it is not walked. When the node is not a dir node, the remaining items in this tree are skipped.

Setting ignore to true tells Walk that it should not visit the node again. For tree nodes, this means that the function is not called for the referenced tree. If the node is not a tree, and all nodes in the current tree have ignore set to true, the current tree will not be visited again. When err is not nil and different from ErrSkipNode, the value returned for ignore is ignored.

Jump to

Keyboard shortcuts

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