MCPcopy
hub / github.com/rs/zerolog / InterfaceMarshalFunc

Function InterfaceMarshalFunc

internal/testcases.go:363–377  ·  view source on GitHub ↗

inline copy from globals.go of InterfaceMarshalFunc used in tests to avoid import cycle

(v interface{})

Source from the content-addressed store, hash-verified

361
362// inline copy from globals.go of InterfaceMarshalFunc used in tests to avoid import cycle
363func InterfaceMarshalFunc(v interface{}) ([]byte, error) {
364 var buf bytes.Buffer
365 encoder := json.NewEncoder(&buf)
366 encoder.SetEscapeHTML(false)
367 err := encoder.Encode(v)
368 if err != nil {
369 return nil, err
370 }
371 b := buf.Bytes()
372 if len(b) > 0 {
373 // Remove trailing \n which is added by Encode.
374 return b[:len(b)-1], nil
375 }
376 return b, nil
377}

Callers 6

TestAppendInterfaceFunction · 0.92
TestAppendStringerFunction · 0.92
TestAppendStringerFunction · 0.92
writeFieldsMethod · 0.85
initFunction · 0.85
initFunction · 0.85

Calls 1

BytesMethod · 0.45

Tested by 3

TestAppendInterfaceFunction · 0.74
TestAppendStringerFunction · 0.74
TestAppendStringerFunction · 0.74