MCPcopy Create free account
hub / github.com/coder/slog / encodeJSON

Function encodeJSON

map.go:136–146  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

134}
135
136func encodeJSON(v interface{}) []byte {
137 b, err := json.Marshal(v)
138 if err != nil {
139 return encode(M(
140 Error(xerrors.Errorf("failed to marshal to JSON: %w", err)),
141 F("type", reflect.TypeOf(v)),
142 F("value", fmt.Sprintf("%+v", v)),
143 ))
144 }
145 return b
146}
147
148func errorChain(f xerrors.Formatter) []interface{} {
149 var errs []interface{}

Callers 2

encodeFunction · 0.85
encodeStructFunction · 0.85

Calls 5

encodeFunction · 0.85
MFunction · 0.85
FFunction · 0.85
ErrorfMethod · 0.80
ErrorFunction · 0.70

Tested by

no test coverage detected