AddPath adds a path to the tree
(parts []string, result *baseline.Baseline)
| 34 | |
| 35 | // AddPath adds a path to the tree |
| 36 | func (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 |
| 62 | func (tn *TreeNode) RenderTree(prefix string, isLast bool, color bool) string { |
no test coverage detected