MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / Set

Function Set

internal/editorconfig/keypath.go:80–94  ·  view source on GitHub ↗

Set assigns value at parts inside data, creating intermediate maps as needed. Existing non-map intermediates are overwritten with a fresh map.

(data map[string]any, parts []string, value any)

Source from the content-addressed store, hash-verified

78// Set assigns value at parts inside data, creating intermediate maps as
79// needed. Existing non-map intermediates are overwritten with a fresh map.
80func Set(data map[string]any, parts []string, value any) {
81 if len(parts) == 0 {
82 return
83 }
84 cursor := data
85 for _, part := range parts[:len(parts)-1] {
86 next, ok := cursor[part].(map[string]any)
87 if !ok {
88 next = map[string]any{}
89 cursor[part] = next
90 }
91 cursor = next
92 }
93 cursor[parts[len(parts)-1]] = value
94}
95
96// Unset removes the leaf at parts from data and reports whether the key
97// existed. Intermediate maps are not pruned.

Callers 7

ApplyFunction · 0.92
applyCodexWireAPIFunction · 0.92
TestSetGetUnsetRoundTripFunction · 0.92
legacyApplyValueFunction · 0.92
SetMethod · 0.85
SetMethod · 0.85
SetMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestSetGetUnsetRoundTripFunction · 0.74