filetree

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package filetree provides functionality for creating ASCII tree representations of directory structures. It converts a list of file paths into a visual tree format that clearly shows the hierarchy and relationships between directories and files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(paths []string, customRoot string) string

Build provides a convenient way to create and render a file tree in one step. It creates a new FileTree instance, processes the paths, and returns the string representation.

Types

type FileTree

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

FileTree creates ASCII tree representations of directory structures. It maintains an internal map-based representation of the directory hierarchy that can be rendered into a string format.

func New

func New(paths []string) *FileTree

New creates a new FileTree instance and processes the provided paths into an internal tree structure. Each path is split into its components and added to the tree while maintaining the hierarchical relationships.

func (*FileTree) String

func (t *FileTree) String(customRoot string) string

String renders the file tree into a string representation using ASCII characters for the tree structure. It includes an optional custom root name and uses standard tree drawing characters (├──, └──, │) to show the hierarchy.

type Node

type Node map[string]any

Node represents a single node in the file tree structure. It's a map where the key is the name of the directory or file, and the value is either another Node (for directories) or nil (for files).

Jump to

Keyboard shortcuts

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