MCPcopy Create free account
hub / github.com/go-pg/pg / Write

Method Write

types/hex.go:29–45  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

27}
28
29func (enc *HexEncoder) Write(b []byte) (int, error) {
30 if !enc.written {
31 if hasFlag(enc.flags, arrayFlag) {
32 enc.b = append(enc.b, `"\`...)
33 } else if hasFlag(enc.flags, quoteFlag) {
34 enc.b = append(enc.b, '\'')
35 }
36 enc.b = append(enc.b, `\x`...)
37 enc.written = true
38 }
39
40 i := len(enc.b)
41 enc.b = append(enc.b, make([]byte, fasthex.EncodedLen(len(b)))...)
42 fasthex.Encode(enc.b[i:], b)
43
44 return len(b), nil
45}
46
47func (enc *HexEncoder) Close() error {
48 if enc.written {

Callers

nothing calls this directly

Calls 2

EncodeMethod · 0.80
hasFlagFunction · 0.70

Tested by

no test coverage detected