treewalk

package
v0.0.0-...-7c31ad9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

SkipNode is used as a return value from WalkFuncs to indicate that the node named in the call (and all its children) are to be skipped. It only makes sense to return this from the pre-visit function; it's by definition too late after the post-visit function.

Functions

func Walk

func Walk(node Node, preVisit WalkFunc, postVisit WalkFunc) error

Walk recursively descends a tree, calling `preVisit` on each node, then walking children, then calling `postVisit` on the node.

The pre-visit function may add children. The post-visition function may similarly drop references to children (and probably should, to reduce memory use on large trees).

Types

type Node

type Node interface {
	NextChild() Node
}

type WalkFunc

type WalkFunc func(node Node) error

Jump to

Keyboard shortcuts

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