Better box drawing

This commit is contained in:
Ian Gulliver
2020-07-26 19:03:33 +00:00
parent f21d10aac8
commit d3b2ae3030
2 changed files with 12 additions and 8 deletions

View File

@@ -210,7 +210,11 @@ func (d *Device) PathHop(path []*Device, visited map[string]*Device) {
}
func (d *Device) LogHop(prefix string, last bool) {
log.Printf("%s+- %s", prefix, d.Name)
if last {
log.Printf("%s└─ %s", prefix, d.Name)
} else {
log.Printf("%s├─ %s", prefix, d.Name)
}
names := []string{}
for _, next := range d.Beyond {
@@ -224,7 +228,7 @@ func (d *Device) LogHop(prefix string, last bool) {
if last {
next.LogHop(fmt.Sprintf("%s ", prefix), i == len(names) - 1)
} else {
next.LogHop(fmt.Sprintf("%s| ", prefix), i == len(names) - 1)
next.LogHop(fmt.Sprintf("%s ", prefix), i == len(names) - 1)
}
i++
}