MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / findMapKeyIndex

Function findMapKeyIndex

internal/config/config.go:1459–1469  ·  view source on GitHub ↗

findMapKeyIndex returns the index of key node in dst mapping (index of key, not value). Returns -1 when not found.

(mapNode *yaml.Node, key string)

Source from the content-addressed store, hash-verified

1457// findMapKeyIndex returns the index of key node in dst mapping (index of key, not value).
1458// Returns -1 when not found.
1459func findMapKeyIndex(mapNode *yaml.Node, key string) int {
1460 if mapNode == nil || mapNode.Kind != yaml.MappingNode {
1461 return -1
1462 }
1463 for i := 0; i+1 < len(mapNode.Content); i += 2 {
1464 if mapNode.Content[i] != nil && mapNode.Content[i].Value == key {
1465 return i
1466 }
1467 }
1468 return -1
1469}
1470
1471// appendPath appends a key to the path, returning a new slice to avoid modifying the original.
1472func appendPath(path []string, key string) []string {

Callers 3

mergeMappingPreserveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected