Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
d6o committed Apr 8, 2018
1 parent d3abbc3 commit 0884a06
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions gotree.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package main

const (
newLine = "\n"
emptySpace = " "
middleItem = "├── "
newLine = "\n"
emptySpace = " "
middleItem = "├── "
continueItem = "│ "
lastItem = "└── "
lastItem = "└── "
)

type (
tree struct {
text string
text string
items []Tree
}

Expand All @@ -23,7 +23,6 @@ type (
}

printer struct {

}

Printer interface {
Expand All @@ -33,7 +32,7 @@ type (

func New(text string) Tree {
return &tree{
text:text,
text: text,
items: []Tree{},
}
}
Expand Down Expand Up @@ -65,11 +64,7 @@ func newPrinter() Printer {
}

func (p *printer) Print(t Tree) string {
return p.print(t)
}

func (p *printer) print(t Tree) string {
return t.Text() + newLine + p.printItems(t.Items(),[]bool{})
return t.Text() + newLine + p.printItems(t.Items(), []bool{})
}

func (p *printer) printText(text string, spaces []bool) string {
Expand All @@ -95,7 +90,7 @@ func (p *printer) printText(text string, spaces []bool) string {
func (p *printer) printItems(t []Tree, spaces []bool) string {
var result string
for i, f := range t {
last := i == len(t) -1
last := i == len(t)-1
result += p.printText(f.Text(), spaces)
if len(f.Items()) > 0 {
spacesChild := append(spaces, last)
Expand Down

0 comments on commit 0884a06

Please sign in to comment.