tree

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Name     string  `json:"name"`
	Children []*Node `json:"children,omitempty"`
}

Node represents a node in the file tree, typically a file or directory.

type Tree

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

Tree is a filesystem tree generator that walks a directory structure and can output it in multiple formats: string tree, JSON, and Markdown.

func NewTree

func NewTree(fs afero.Fs, path string, exclude ...string) *Tree

NewTree constructs a new Tree given a filesystem interface and root path. You can optionally pass directory/file names to exclude from traversal.

func (*Tree) MakeTree

func (t *Tree) MakeTree() error

MakeTree initiates the tree construction by walking through the filesystem starting from the root path.

func (*Tree) ToJSON

func (t *Tree) ToJSON() (string, error)

ToJSON returns the directory structure encoded in JSON format.

func (*Tree) ToMarkdown

func (t *Tree) ToMarkdown() string

ToMarkdown returns the directory structure in a Markdown list format.

func (*Tree) ToString

func (t *Tree) ToString() string

ToString returns the directory structure in a human-readable "tree" CLI-like format.

Jump to

Keyboard shortcuts

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