package pgio

Import Path
	github.com/jackc/pgx/v5/internal/pgio (on go.dev)

Dependency Relation
	imports 4 packages, and imported by 4 packages

Involved Source Files Package pgio is a low-level toolkit for building and parsing messages in the PostgreSQL wire protocol. pgio provides functions for appending integers to a []byte while doing byte order conversion, and a bounds-checked Reader for parsing binary values from untrusted input. read.go write.go
Package-Level Type Names (only one, which is exported)
/* sort exporteds by: | */
Reader is a bounds-checked reader for the PostgreSQL binary format. It is designed so that decoders of untrusted input cannot forget a length check: every read validates against the remaining bytes, and the first failure sticks. After a failure all subsequent reads return zero values, so a decoder can read an entire structure without intermediate error checks and inspect Err or Finish once at the end. Reads never panic. A decoder that branches on a value it just read (e.g. an element count used to size an allocation) should check Err before acting on the value. (*Reader) Byte() byte Bytes reads the next n bytes. The returned slice aliases the source; it is not a copy. CString reads a NUL-terminated string, returning the bytes before the terminator and consuming the terminator. The returned slice aliases the source; it is not a copy. Count reads an int32 element count and validates it against the remaining bytes: the count must be non-negative, and since each element occupies at least minElemSize bytes, count*minElemSize must not exceed the remaining message. This bounds allocations sized from the count against a malicious or corrupt message claiming a huge count. Returns 0 on any failure. Err returns the first error encountered, if any. Finish returns the first error encountered, or an error if unread bytes remain. Decoders that must consume the entire source should end with Finish. (*Reader) Int16() int16 (*Reader) Int32() int32 (*Reader) Int64() int64 Remaining returns the number of unread bytes. (*Reader) Uint16() uint16 (*Reader) Uint32() uint32 (*Reader) Uint64() uint64 Value reads an int32 length followed by that many bytes — the standard PostgreSQL binary representation of a value. A length of -1 means NULL and returns (nil, true). Any other negative length is an error. The returned slice aliases the source; null is only meaningful if Err returns nil. *Reader : math/rand/v2.Source func NewReader(s []byte) *Reader
Package-Level Functions (total 12, in which 11 are exported)
func SetInt32(buf []byte, n int32)
Uint16Exact returns the big-endian uint16 in src, which must be exactly 2 bytes.
Uint32Exact returns the big-endian uint32 in src, which must be exactly 4 bytes.
Uint64Exact returns the big-endian uint64 in src, which must be exactly 8 bytes.
Package-Level Variables (total 2, both are exported)
ErrInsufficientBytes is wrapped by all Reader errors caused by a read past the end of the source.
ErrInvalidLength is wrapped by the errors returned from the exact-length read functions below.