Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/a8m/tree
An implementation of the Unix tree command written in Go, that can be used programmatically
https://github.com/a8m/tree
go golang tree tree-structure
Last synced: 11 days ago
JSON representation
An implementation of the Unix tree command written in Go, that can be used programmatically
- Host: GitHub
- URL: https://github.com/a8m/tree
- Owner: a8m
- License: mit
- Created: 2016-01-13T15:01:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-04T21:27:47.000Z (10 months ago)
- Last Synced: 2024-10-14T21:04:47.125Z (29 days ago)
- Topics: go, golang, tree, tree-structure
- Language: Go
- Homepage:
- Size: 192 KB
- Stars: 93
- Watchers: 6
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tree [![Build status][travis-image]][travis-url] [![License][license-image]][license-url]
---
> An implementation of the [`tree`](http://mama.indstate.edu/users/ice/tree/) command written in Go, that can be used programmatically.#### Installation:
```sh
$ go get github.com/a8m/tree/cmd/tree
```#### How to use `tree` programmatically ?
You can take a look on [`cmd/tree`](https://github.com/a8m/tree/blob/master/cmd/tree/tree.go), and [s3tree](http://github.com/a8m/s3tree) or see the example below.
```go
import (
"github.com/a8m/tree"
)func main() {
opts := &tree.Options{
// Fs, and OutFile are required fields.
// fs should implement the tree file-system interface(see: tree.Fs),
// and OutFile should be type io.Writer
Fs: fs,
OutFile: os.Stdout,
// ...
}
inf.New("root-dir")
// Visit all nodes recursively
inf.Visit(opts)
// Print nodes
inf.Print(opts)
}
```### License
MIT[travis-image]: https://img.shields.io/travis/a8m/tree.svg?style=flat-square
[travis-url]: https://travis-ci.org/a8m/tree
[license-image]: http://img.shields.io/npm/l/deep-keys.svg?style=flat-square
[license-url]: LICENSE