MCPcopy
hub / github.com/grafana/tempo / toMap

Function toMap

cmd/tempo-cli/cmd-migrate-overrides-config.go:84–94  ·  view source on GitHub ↗

toMap converts a struct to a normalized map[string]interface{} via yaml round-trip. All nested maps are normalized to map[string]interface{}.

(v interface{})

Source from the content-addressed store, hash-verified

82// toMap converts a struct to a normalized map[string]interface{} via yaml round-trip.
83// All nested maps are normalized to map[string]interface{}.
84func toMap(v interface{}) (map[string]interface{}, error) {
85 b, err := yaml.Marshal(v)
86 if err != nil {
87 return nil, err
88 }
89 var m map[string]interface{}
90 if err := yaml.Unmarshal(b, &m); err != nil {
91 return nil, err
92 }
93 return normalizeMap(m), nil
94}
95
96// normalizeMap recursively converts all map[interface{}]interface{} to map[string]interface{}.
97func normalizeMap(m map[string]interface{}) map[string]interface{} {

Callers 2

RunMethod · 0.85
RunMethod · 0.85

Calls 3

normalizeMapFunction · 0.85
MarshalMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected