import "github.com/cockroachdb/cockroach/pkg/util/treeprinter"
type Node struct {
// contains filtered or unexported fields
}
Node is a handle associated with a specific depth in a tree. See below for sample usage.
New creates a tree printer and returns a sentinel node reference which should be used to add the root. Sample usage:
tp := New() root := n.Child("root") root.Child("child-1") root.Child("child-2").Child("grandchild\ngrandchild-more-info") root.Child("child-3") fmt.Print(tp.String())
Output:
root ├── child-1 ├── child-2 │ └── grandchild │ grandchild-more-info └── child-3
Note that the Child calls can't be rearranged arbitrarily; they have to be in the order they need to be displayed (depth-first pre-order).
NewWithIndent creates a tree printer like New, permitting customization of the width of the outputted tree. leftPad controls whether the tree lines are padded from the first character of their parent. rightPad controls whether children are separated from their edges by a space. edgeLength controls how many characters wide each edge is.
AddEmptyLine adds an empty line to the output; used to introduce vertical spacing as needed.
AddLine adds a new line to a child node without an edge.
Child adds a node as a child of the given node. Multi-line strings are supported with appropriate indentation.
Childf adds a node as a child of the given node.
FormattedRows returns the formatted rows. Can only be called on the result of treeprinter.New.
Package treeprinter imports 3 packages (graph) and is imported by 19 packages. Updated 2019-09-15. Refresh now. Tools for package owners.