MCPcopy Create free account
hub / github.com/chainreactors/spray / AddPath

Method AddPath

core/format.go:36–59  ·  view source on GitHub ↗

AddPath adds a path to the tree

(parts []string, result *baseline.Baseline)

Source from the content-addressed store, hash-verified

34
35// AddPath adds a path to the tree
36func (tn *TreeNode) AddPath(parts []string, result *baseline.Baseline) {
37 if len(parts) == 0 {
38 tn.Result = result
39 tn.IsLeaf = true
40 return
41 }
42
43 part := parts[0]
44 if part == "" {
45 if len(parts) > 1 {
46 tn.AddPath(parts[1:], result)
47 } else {
48 tn.Result = result
49 tn.IsLeaf = true
50 }
51 return
52 }
53
54 if _, exists := tn.Children[part]; !exists {
55 tn.Children[part] = NewTreeNode(part)
56 }
57
58 tn.Children[part].AddPath(parts[1:], result)
59}
60
61// RenderTree renders the tree structure
62func (tn *TreeNode) RenderTree(prefix string, isLast bool, color bool) string {

Callers 1

formatTreeFunction · 0.95

Calls 1

NewTreeNodeFunction · 0.85

Tested by

no test coverage detected