Generate a tree structure from an indented text.
$ go get -u github.com/mauricioklein/go-spacetree/spacetree
import (
"os"
"bufio"
"github.com/mauricioklein/go-spacetree/spacetree"
)
// Generate a *bufio.Scanner with the indented content from a file
file, err := os.Open("PUT THE FILEPATH HERE")
if err != nil {
panic(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
// Define the indentation symbol used on the file
identationSymbol := "\t" // file is indented by tabs
// Generate the tree
// Returns a *spacetree.Node, holding the tree's root node
root, err := spacetree.New(scanner, indentationSymbol)
Runnable examples can be found here.
$ go test -v ./...
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Spacetree is licensed under the MIT License.