MCPcopy Create free account
hub / github.com/belak/gitdir / RemoveKey

Method RemoveKey

internal/yaml/operations.go:10–22  ·  view source on GitHub ↗

RemoveKey will remove a given key and value from a MappingNode.

(key string)

Source from the content-addressed store, hash-verified

8
9// RemoveKey will remove a given key and value from a MappingNode.
10func (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.
25type EnsureOptions struct {

Callers 1

ensureAdminUserYamlFunction · 0.80

Calls 2

KeyIndexMethod · 0.95
removeFunction · 0.85

Tested by

no test coverage detected