Skip to content
Snippets Groups Projects

Path traversal demo

Merged Ghost User requested to merge path-traversal-demo into 67-overhaul-architecture
1 file
+ 22
4
Compare changes
  • Side-by-side
  • Inline
@@ -11,6 +11,22 @@ type PathElement struct {
Name string
}
func (p *PathElement)Print() {
printPE(0, p)
}
func printPE(indent int, pe *PathElement) {
for i := 0; i < indent; i++ {
fmt.Print(" ")
}
fmt.Println(pe.Name)
if len(pe.Children) > 0 {
for _,p := range pe.Children {
printPE(indent+1, p)
}
}
}
func main() {
tree := schema.SchemaTree
paths := make(map[string]*PathElement)
@@ -18,11 +34,12 @@ func main() {
for k,v := range tree {
if v.Parent != nil {
if v.Parent.Name == "device" {
paths[k] = processEntry(v)
pathElement := processEntry(v)
pathElement.Print()
paths[k] = pathElement
}
}
}
fmt.Println("stop")
}
func processEntry(e *yang.Entry) *PathElement {
@@ -31,9 +48,10 @@ func processEntry(e *yang.Entry) *PathElement {
Children: make([]*PathElement, len(e.Dir)),
Name: e.Name,
}
i := 0
for _,v := range e.Dir {
child := processEntry(v)
elem.Children = append(elem.Children, child)
elem.Children[i] = processEntry(v)
i++
}
return elem
}
Loading