RemoveKey will remove a given key and value from a MappingNode.
(key string)
| 8 | |
| 9 | // RemoveKey will remove a given key and value from a MappingNode. |
| 10 | func (n *Node) RemoveKey(key string) bool { |
| 11 | idx := n.KeyIndex(key) |
| 12 | if idx == -1 { |
| 13 | return false |
| 14 | } |
| 15 | |
| 16 | // Removing the index of the target node twice should drop the key and |
| 17 | // value. |
| 18 | n.Content = remove(n.Content, idx) |
| 19 | n.Content = remove(n.Content, idx) |
| 20 | |
| 21 | return true |
| 22 | } |
| 23 | |
| 24 | // EnsureOptions are optional settings when using Node.EnsureKey. |
| 25 | type EnsureOptions struct { |
no test coverage detected