Clone returns a copy of the provided node
(node *yaml.Node)
| 27 | |
| 28 | // Clone returns a copy of the provided node |
| 29 | func Clone(node *yaml.Node) *yaml.Node { |
| 30 | if node == nil { |
| 31 | return nil |
| 32 | } |
| 33 | |
| 34 | out := &yaml.Node{ |
| 35 | Kind: node.Kind, |
| 36 | Style: node.Style, |
| 37 | Tag: node.Tag, |
| 38 | Value: node.Value, |
| 39 | Anchor: node.Anchor, |
| 40 | Alias: Clone(node.Alias), |
| 41 | Content: make([]*yaml.Node, len(node.Content)), |
| 42 | HeadComment: node.HeadComment, |
| 43 | LineComment: node.LineComment, |
| 44 | FootComment: node.FootComment, |
| 45 | Line: node.Line, |
| 46 | Column: node.Column, |
| 47 | } |
| 48 | |
| 49 | for i, child := range node.Content { |
| 50 | out.Content[i] = Clone(child) |
| 51 | } |
| 52 | |
| 53 | return out |
| 54 | } |
| 55 | |
| 56 | // Returns the parent node of node, paired with its name if it's a map pair. |
| 57 | // If it is not a map pair, only NodePair.Value is not nil. |
no outgoing calls
no test coverage detected