MCPcopy
hub / github.com/jackc/pgx / Encode

Method Encode

pgproto3/negotiate_protocol_version.go:56–65  ·  view source on GitHub ↗

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

(dst []byte)

Source from the content-addressed store, hash-verified

54
55// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
56func (src *NegotiateProtocolVersion) Encode(dst []byte) ([]byte, error) {
57 dst, sp := beginMessage(dst, 'v')
58 dst = pgio.AppendUint32(dst, src.NewestMinorProtocol)
59 dst = pgio.AppendUint32(dst, uint32(len(src.UnrecognizedOptions)))
60 for _, option := range src.UnrecognizedOptions {
61 dst = append(dst, option...)
62 dst = append(dst, 0)
63 }
64 return finishMessage(dst, sp)
65}
66
67// MarshalJSON implements encoding/json.Marshaler.
68func (src NegotiateProtocolVersion) MarshalJSON() ([]byte, error) {

Callers 1

Calls 3

AppendUint32Function · 0.92
beginMessageFunction · 0.85
finishMessageFunction · 0.85

Tested by 1