MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / nestedMapSet

Function nestedMapSet

options/options.go:381–397  ·  view source on GitHub ↗

nestedMapSet sets a value in a nested map[string]any structure. If the key has more than one element, it creates nested maps as needed.

(m map[string]any, key string, value any)

Source from the content-addressed store, hash-verified

379// nestedMapSet sets a value in a nested map[string]any structure.
380// If the key has more than one element, it creates nested maps as needed.
381func nestedMapSet(m map[string]any, key string, value any) {
382 key, rest, isGroup := strings.Cut(key, ".")
383
384 if !isGroup {
385 m[key] = value
386 return
387 }
388
389 mm, ok := m[key].(map[string]any)
390 if !ok {
391 mm = make(map[string]any)
392 }
393
394 nestedMapSet(mm, rest, value)
395
396 m[key] = mm
397}
398
399func toSlogValue(v any) slog.Value {
400 m, ok := v.(map[string]any)

Callers 1

nestedMapMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected