Documentation
¶
Overview ¶
Package treeprint provides a simple ASCII tree composing tool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type StructTreeOption ¶
type StructTreeOption int
const ( StructNameTree StructTreeOption = iota StructValueTree StructTagTree StructTypeTree StructTypeSizeTree )
type Tree ¶
type Tree interface {
// AddNode adds a new node to a branch.
AddNode(v Value) Tree
// AddMetaNode adds a new node with meta value provided to a branch.
AddMetaNode(meta MetaValue, v Value) Tree
// AddBranch adds a new branch node (a level deeper).
AddBranch(v Value) Tree
// AddMetaBranch adds a new branch node (a level deeper) with meta value provided.
AddMetaBranch(meta MetaValue, v Value) Tree
// Branch converts a leaf-node to a branch-node,
// applying this on a branch-node does no effect.
Branch() Tree
// FindByMeta finds a node whose meta value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByMeta(meta MetaValue) Tree
// FindByValue finds a node whose value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByValue(value Value) Tree
// returns the last node of a tree
FindLastNode() Tree
// String renders the tree or subtree as a string.
String() string
// Bytes renders the tree or subtree as byteslice.
Bytes() []byte
SetValue(value Value)
SetMetaValue(meta MetaValue)
}
Tree represents a tree structure with leaf-nodes and branch-nodes.
func FromStruct ¶
func FromStruct(v interface{}, opt ...StructTreeOption) (Tree, error)
func FromStructWithMeta ¶
Click to show internal directories.
Click to hide internal directories.