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

Method Encode

pgproto3/startup_message.go:72–86  ·  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

70
71// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
72func (src *StartupMessage) Encode(dst []byte) ([]byte, error) {
73 sp := len(dst)
74 dst = pgio.AppendInt32(dst, -1)
75
76 dst = pgio.AppendUint32(dst, src.ProtocolVersion)
77 for k, v := range src.Parameters {
78 dst = append(dst, k...)
79 dst = append(dst, 0)
80 dst = append(dst, v...)
81 dst = append(dst, 0)
82 }
83 dst = append(dst, 0)
84
85 return finishMessage(dst, sp)
86}
87
88// MarshalJSON implements encoding/json.Marshaler.
89func (src StartupMessage) MarshalJSON() ([]byte, error) {

Callers 1

TestStartupMessageFunction · 0.95

Calls 3

AppendInt32Function · 0.92
AppendUint32Function · 0.92
finishMessageFunction · 0.85

Tested by 1

TestStartupMessageFunction · 0.76