https://github.com/noahingh/tree
Display content recursively as tree-like format.
https://github.com/noahingh/tree
Last synced: about 1 year ago
JSON representation
Display content recursively as tree-like format.
- Host: GitHub
- URL: https://github.com/noahingh/tree
- Owner: noahingh
- License: mit
- Created: 2019-12-25T16:28:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-01T03:25:26.000Z (over 6 years ago)
- Last Synced: 2025-03-27T08:34:02.639Z (about 1 year ago)
- Language: Go
- Size: 39.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tree
[](https://cloud.drone.io/hanjunlee/tree) [](https://godoc.org/github.com/hanjunlee/tree)
Package tree help to display content recursively as tree-like format.
## Usage
**code**
```go
package main
import (
"fmt"
"github.com/hanjunlee/tree"
)
type file string
func (f file) String() string {
return string(f)
}
func (f file) Less(comp tree.Item) bool {
return string(f) < string(comp.(file))
}
func main() {
t := tree.NewTree(file("root"))
t.Move(file("dir0"), file("root"))
t.Move(file("dir1"), file("root"))
t.Move(file("file 0"), file("dir0"))
t.Move(file("file 1"), file("dir0"))
t.Move(file("file 2"), file("dir1"))
result, _ := t.Render()
for _, l := range result {
fmt.Println(l)
}
}
```
**output**
```output
root
├── dir 0
│ ├── file 0
│ └── file 1
└── dir 1
└── file 2
```