tree

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 3 Imported by: 1

README

Go Report Card GitHub license GoDoc

tree

tree is tree viewer.

minimal example:

func ExampleTree() {
	artist := tree.New("Pantera")
	album := tree.New("Far Beyond Driven")
	album.Add("5 minutes Alone")
	album.Add("Some another")
	artist.Add(album)
	artist.Add("Power Metal")
	fmt.Fprintf(os.Stdout, "%s\n", artist)

	// Output:
	// Pantera
	// ├──Far Beyond Driven
	// │  ├──5 minutes Alone
	// │  └──Some another
	// └──Power Metal
}

Documentation:

package tree // import "github.com/Konstantin8105/tree"

Package tree create and print tree.

TYPES

type Tree struct {
	Name string
	// Has unexported fields.
}
    Tree struct of tree

func New(name string) (tr *Tree)
    New returns a new tree

func (t *Tree) Add(node interface{})
    Add node in tree

func (t Tree) String() (out string)
    String return string with tree view

Documentation

Overview

Package tree create and print tree.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

type Tree struct {
	Name string
	// contains filtered or unexported fields
}

Tree struct of tree

Example
package main

import (
	"fmt"
	"os"

	"github.com/Konstantin8105/tree"
)

func main() {
	artist := tree.New("Pantera")
	album := tree.New("Far Beyond Driven")
	album.Add("5 minutes Alone")
	album.Add("Some another")
	artist.Add(album)
	artist.Add("Power Metal")
	fmt.Fprintf(os.Stdout, "%s\n", artist)

}
Output:

Pantera
├──Far Beyond Driven
│  ├──5 minutes Alone
│  └──Some another
└──Power Metal

func New

func New(name string) (tr *Tree)

New returns a new tree

func (*Tree) Add

func (t *Tree) Add(node interface{})

Add node in tree

func (Tree) String

func (t Tree) String() (out string)

String return string with tree view

Jump to

Keyboard shortcuts

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