1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
# tree/demo

```go
package main
import (
"github.com/pterm/pterm"
)
func main() {
// Define a tree structure using pterm.TreeNode
tree := pterm.TreeNode{
// The top node of the tree
Text: "Top node",
// The children of the top node
Children: []pterm.TreeNode{{
// A child node
Text: "Child node",
// The children of the child node
Children: []pterm.TreeNode{
// Grandchildren nodes
{Text: "Grandchild node"},
{Text: "Grandchild node"},
{Text: "Grandchild node"},
},
}},
}
// Render the tree with the defined structure as the root
pterm.DefaultTree.WithRoot(tree).Render()
}
```
|