MCPcopy Create free account
hub / github.com/docker/compose / valueOrDefault

Function valueOrDefault

internal/tracing/docker_context.go:118–123  ·  view source on GitHub ↗

valueOrDefault returns the type-cast value at the specified key in the map if present and the correct type; otherwise, it returns the default value for T.

(m map[string]any, key string)

Source from the content-addressed store, hash-verified

116// if present and the correct type; otherwise, it returns the default value for
117// T.
118func valueOrDefault[T any](m map[string]any, key string) T {
119 if v, ok := m[key].(T); ok {
120 return v
121 }
122 return *new(T)
123}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected