tree

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal[T comparable](root NodeMarshaler[T]) ([]byte, error)

func Stringify

func Stringify[T comparable](node Node[T], options *Options) string

Stringify converts node to string

Types

type Node

type Node[T comparable] interface {
	String() string          // String returns node self information
	Parent() T               // Parent returns parent node or nil
	NumChild() int           // NumChild returns number of child
	GetChildByIndex(i int) T // GetChildByIndex gets child by index
}

Node represents a generic printable node

type NodeMarshaler

type NodeMarshaler[T comparable] interface {
	Node[T]
	Marshal() ([]byte, error)
}

type Options

type Options struct {
	Prefix     string
	Parent     string // default "│  "
	Space      string // default "   "
	Branch     string // default "├──"
	LastBranch string // default "└──"
}

Options represents a options for stringify Node

Jump to

Keyboard shortcuts

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