Added Print() Method to FileNode Struct

This Method Is Useful for Printing the Children of the Node
recursively. Useful for debugging Purpose.
This commit is contained in:
aditya-K2 2021-10-11 13:54:51 +05:30
parent 99e0e8e615
commit 91de613758

View File

@ -46,6 +46,18 @@ func generateDirectoryTree(path [] string) *FileNode{
} }
head = head1 head = head1
} }
fmt.Println(head)
return head return head
} }
func (f FileNode) Print(count int){
if (len(f.children) == 0){
return
} else{
for i := range f.children{
for j := 0 ; j < count ; j++ {
fmt.Print("---")
}; fmt.Println(f.children[i].path)
f.children[i].Print(count + 1)
}
}
}