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

Method safeAddByteString

zapcore/json_encoder.go:498–505  ·  view source on GitHub ↗

safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte.

(s []byte)

Source from the content-addressed store, hash-verified

496
497// safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte.
498func (enc *jsonEncoder) safeAddByteString(s []byte) {
499 safeAppendStringLike(
500 (*buffer.Buffer).AppendBytes,
501 utf8.DecodeRune,
502 enc.buf,
503 s,
504 )
505}
506
507// safeAppendStringLike is a generic implementation of safeAddString and safeAddByteString.
508// It appends a string or byte slice to the buffer, escaping all special characters.

Callers 3

AppendByteStringMethod · 0.95
TestJSONEscapingFunction · 0.95

Calls 1

safeAppendStringLikeFunction · 0.85

Tested by 2

TestJSONEscapingFunction · 0.76