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

Method KeyIndex

internal/yaml/node.go:55–63  ·  view source on GitHub ↗

KeyIndex finds the index of the given key or -1 if not found. Note that it will only return an index if index + 1 also exists.

(key string)

Source from the content-addressed store, hash-verified

53// KeyIndex finds the index of the given key or -1 if not found. Note that it
54// will only return an index if index + 1 also exists.
55func (n *Node) KeyIndex(key string) int {
56 for i := 0; i+1 < len(n.Content); i += 2 {
57 if n.Content[i].Kind == yaml.ScalarNode && n.Content[i].Value == key {
58 return i
59 }
60 }
61
62 return -1
63}
64
65// ValueNode returns the given value node for a key, or nil if not found.
66func (n *Node) ValueNode(key string) *Node {

Callers 2

ValueNodeMethod · 0.95
RemoveKeyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected