MCPcopy
hub / github.com/uber-go/zap / zapEncode

Function zapEncode

zapcore/json_encoder_impl_test.go:597–609  ·  view source on GitHub ↗
(encode func(*jsonEncoder, string))

Source from the content-addressed store, hash-verified

595}
596
597func zapEncode(encode func(*jsonEncoder, string)) func(s string) []byte {
598 return func(s string) []byte {
599 enc := &jsonEncoder{buf: bufferpool.Get()}
600 // Escape and quote a string using our encoder.
601 var ret []byte
602 encode(enc, s)
603 ret = make([]byte, 0, enc.buf.Len()+2)
604 ret = append(ret, '"')
605 ret = append(ret, enc.buf.Bytes()...)
606 ret = append(ret, '"')
607 return ret
608 }
609}
610
611func roundTripsCorrectly(encode func(string) []byte, original string) bool {
612 // Encode using our encoder, decode using the standard library, and assert

Callers 2

Calls 3

BytesMethod · 0.80
GetMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected