Skip to content

Commit

Permalink
Add runnable example to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauricio Klein committed May 3, 2019
1 parent 9f13cfd commit a1fc61a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ $ go get -u github.com/mauricioklein/go-spacetree/spacetree
root := spacetree.New(scanner, indentationSymbol)
```

Runnable examples can be found [here](examples/).

## Tests

```bash
Expand Down
26 changes: 26 additions & 0 deletions examples/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"bufio"
"fmt"
"os"

"github.com/mauricioklein/go-spacetree/spacetree"
)

func main() {
file, err := os.Open("../test_input/multiple_levels_with_spaces.txt")

if err != nil {
panic(err)
}

defer file.Close()

scanner := bufio.NewScanner(file)
indentationSymbol := " " // File is indented by two consecutive spaces

root := spacetree.New(scanner, indentationSymbol)

fmt.Printf("Root: %+v\n", root)
}

0 comments on commit a1fc61a

Please sign in to comment.