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

Function Unset

internal/editorconfig/keypath.go:98–116  ·  view source on GitHub ↗

Unset removes the leaf at parts from data and reports whether the key existed. Intermediate maps are not pruned.

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

Source from the content-addressed store, hash-verified

96// Unset removes the leaf at parts from data and reports whether the key
97// existed. Intermediate maps are not pruned.
98func Unset(data map[string]any, parts []string) bool {
99 if len(parts) == 0 {
100 return false
101 }
102 cursor := data
103 for _, part := range parts[:len(parts)-1] {
104 next, ok := cursor[part].(map[string]any)
105 if !ok {
106 return false
107 }
108 cursor = next
109 }
110 leaf := parts[len(parts)-1]
111 if _, ok := cursor[leaf]; !ok {
112 return false
113 }
114 delete(cursor, leaf)
115 return true
116}
117
118// Flatten returns data as a map of dotted key paths to stringified values,
119// prefixed with prefix. Slices are flattened by index.

Callers 8

ApplyFunction · 0.92
applyCodexWireAPIFunction · 0.92
TestSetGetUnsetRoundTripFunction · 0.92
legacyUnsetConfigFunction · 0.92
UnsetMethod · 0.85
UnsetMethod · 0.85
UnsetMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestSetGetUnsetRoundTripFunction · 0.74