Documentation
¶
Overview ¶
Package tree implements a tree data structure for representing a directory structure.
It provides methods for adding paths, checking for the presence of a path, generating a string representation of the tree, getting all paths in the tree, and retrieving a random path.
It leverages the github.com/xlab/treeprint package to generate the string representation. The implementation is concurrent-safe through the use of a sync.RWMutex.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDirectoryPaths ¶
AddDirectoryPaths is a helper function that adds all paths in a directory to the tree you can optionally pass in a prefix to trim from the paths.
Types ¶
type Tree ¶
type Tree interface {
// Add adds a path to the tree
Add(paths ...string)
// HasPath checks if any of the paths in the tree contain the given path
HasPath(path string) bool
// ToString gets a string representation of the tree
ToString() string
// AllPaths gets all paths in the tree. This will include paths that might not have been explicitly added
// e.g. if you Add() a/b/c/d.go, AllPaths() will return a/b/c/d.go, a/b/c a/b/ and a/
AllPaths() []string
}
Tree is a tree data structure for representing a directory structure.
Click to show internal directories.
Click to hide internal directories.