pgx

package module
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2014 License: MIT Imports: 22 Imported by: 2,313

README

pgx

PostgreSQL client library for Go

Description

pgx is a database connection library designed specifically for PostgreSQL. pgx offers an interface similar to database/sql that offers more performance and features than are available the database/sql interface. It also can run as a database/sql compatible driver by importing github.com/jackc/pgx/stdlib.

Features

Below are some of the standout features of pgx.

Familiar Query Interface

pgx implements Query, QueryRow, and Scan in the familiar database/sql style.

var name string
var weight int64
err := conn.QueryRow("select name, weight from widgets where id=$1", 42).Scan(&name, &weight)
if err != nil {
    return err
}

pgx adds convenience to Query in that it is only necessary to call Close if you want to ignore the rest of the rows. When Next has read all rows or an error occurs, the rows are closed automatically.

var sum int32

rows, err := conn.Query("select generate_series(1,$1)", 10)
if err != nil {
    t.Fatalf("conn.Query failed: ", err)
}

for rows.Next() {
    var n int32
    rows.Scan(&n)
    sum += n
}

// rows.Close implicitly called when rows.Next is finished

if rows.Err() != nil {
    t.Fatalf("conn.Query failed: ", err)
}

// ...
Prepared Statements

Prepared statements are easy to use in pgx. Just call Prepare with the name of the statement and the SQL. To execute a prepared statement just pass the name of the statement into a Query, QueryRow, or Exec as the SQL text. It will automatically detect that it is the name of a prepared statement and execute it.

if _, err := conn.Prepare("getTime", "select now()"); err == nil {
    // handle err
}

var t time.Time
err := conn.QueryRow("getTime").Scan(&t)
if err != nil {
    return err
}

Prepared statements will use the binary transmission when possible. This can substantially increase performance.

Explicit Connection Pool

Connection pool usage is explicit and configurable. In pgx, a connection can be created and managed directly, or a connection pool with a configurable maximum connections can be used. Also, the connection pool offers an after connect hook that allows every connection to be automatically setup before being made available in the connection pool. This is especially useful to ensure all connections have the same prepared statements available or to change any other connection settings.

It delegates Query, QueryRow, Exec, and Begin functions to an automatically checked out and released connection so you can avoid manually acquiring and releasing connections when you do not need that level of control.

var name string
var weight int64
err := pool.QueryRow("select name, weight from widgets where id=$1", 42).Scan(&name, &weight)
if err != nil {
    return err
}
Transactions

Transactions are started by calling Begin or BeginIso. The BeginIso variant creates a transaction with a specified isolation level.

    tx, err := conn.Begin()
    if err != nil {
        t.Fatalf("conn.Begin failed: %v", err)
    }

    _, err = tx.Exec("insert into foo(id) values (1)")
    if err != nil {
        t.Fatalf("tx.Exec failed: %v", err)
    }

    err = tx.Commit()
    if err != nil {
        t.Fatalf("tx.Commit failed: %v", err)
    }
})
Listen / Notify

Pgx can listen to the PostgreSQL notification system with the WaitForNotification function. It takes a maximum time to wait for a notification.

if notification, err := conn.WaitForNotification(time.Second); err != nil {
    // do something with notification
}
TLS

The pgx ConnConfig struct has a TLSConfig field. If this field is nil, then TLS will be disabled. If it is present, then it will be used to configure the TLS connection.

Custom Type Support

pgx includes support for the common data types like integers, floats, strings, dates, and times that have direct mappings between Go and SQL. Support can be added for additional types like point, hstore, numeric, etc. that do not have direct mappings in Go by the types implementing Scanner, TextEncoder, and optionally BinaryEncoder. To enable binary format for custom types, a prepared statement must be used and the field description of the returned field must have FormatCode set to BinaryFormatCode. See example_custom_type_test.go for an example of a custom type for the PostgreSQL point type.

Null Mapping

pgx includes Null* types in a similar fashion to database/sql that implement the necessary interfaces to be encoded and scanned.

Logging

pgx connections optionally accept a logger from the log15 package.

Testing

Pgx supports multiple connection and authentication types. Setting up a test environment that can test all of them can be cumbersome. In particular, Windows cannot test Unix domain socket connections. Because of this pgx will skip tests for connection types that are not configured.

Normal Test Environment

To setup the normal test environment run the following SQL:

create user pgx_md5 password 'secret';
create database pgx_test;

Next open connection_settings_test.go.example and make a copy without the .example. If your PostgreSQL server is accepting connections on 127.0.0.1, then you are done.

Connection and Authentication Test Environment

Complete the normal test environment setup and also do the following.

Run the following SQL:

create user pgx_none;
create user pgx_pw password 'secret';

Add the following to your pg_hba.conf:

If you are developing on Unix with domain socket connections:

local  pgx_test  pgx_none  trust
local  pgx_test  pgx_pw    password
local  pgx_test  pgx_md5   md5

If you are developing on Windows with TCP connections:

host  pgx_test  pgx_none  127.0.0.1/32 trust
host  pgx_test  pgx_pw    127.0.0.1/32 password
host  pgx_test  pgx_md5   127.0.0.1/32 md5

Documentation

Overview

Package pgx is a PostgreSQL database driver.

pgx provides lower level access to PostgreSQL than the standard database/sql It remains as similar to the database/sql interface as possible while providing better speed and access to PostgreSQL specific features. Import github.com/jack/pgx/stdlib to use pgx as a database/sql compatible driver.

Index

Constants

View Source
const (
	Serializable    = "serializable"
	RepeatableRead  = "repeatable read"
	ReadCommitted   = "read committed"
	ReadUncommitted = "read uncommitted"
)

Transaction isolation levels

View Source
const (
	BoolOid        = 16
	ByteaOid       = 17
	Int8Oid        = 20
	Int2Oid        = 21
	Int4Oid        = 23
	TextOid        = 25
	Float4Oid      = 700
	Float8Oid      = 701
	VarcharOid     = 1043
	DateOid        = 1082
	TimestampOid   = 1114
	TimestampTzOid = 1184
)

PostgreSQL oids for common types

View Source
const (
	TextFormatCode   = 0
	BinaryFormatCode = 1
)

PostgreSQL format codes

View Source
const (
	NullText   = iota
	SafeText   = iota
	UnsafeText = iota
)

EncodeText statuses

Variables

View Source
var ErrDeadConn = errors.New("conn is dead")
View Source
var ErrNoRows = errors.New("no rows in result set")
View Source
var ErrNotificationTimeout = errors.New("notification timeout")
View Source
var ErrTxClosed = errors.New("tx is closed")

Functions

func QuoteIdentifier

func QuoteIdentifier(input string) (output string)

QuoteIdentifier escapes and quotes an identifier making it safe for interpolation into an SQL string

func QuoteString

func QuoteString(input string) (output string)

QuoteString escapes and quotes a string making it safe for interpolation into an SQL string.

func SanitizeSql

func SanitizeSql(sql string, args ...interface{}) (output string, err error)

SanitizeSql substitutely args positionaly into sql. Placeholder values are $ prefixed integers like $1, $2, $3, etc. args are sanitized and quoted as appropriate.

Types

type BinaryEncoder

type BinaryEncoder interface {
	// EncodeBinary writes the binary value to w.
	//
	// EncodeBinary MUST check oid to see if the parameter data type is
	// compatible. If this is not done, the PostgreSQL server may detect the
	// error if the expected data size or format of the encoded data does not
	// match. But if the encoded data is a valid representation of the data type
	// PostgreSQL expects such as date and int4, incorrect data may be stored.
	EncodeBinary(w *WriteBuf, oid Oid) error
}

BinaryEncoder is an interface used to encode values in binary format for transmission to the PostgreSQL server. It is used by prepared queries.

type CommandTag

type CommandTag string

func (CommandTag) RowsAffected

func (ct CommandTag) RowsAffected() int64

RowsAffected returns the number of rows affected. If the CommandTag was not for a row affecting command (such as "CREATE TABLE") then it returns 0

type Conn

type Conn struct {
	Pid           int32             // backend pid
	SecretKey     int32             // key to use to send a cancel query message to the server
	RuntimeParams map[string]string // parameters that have been reported by the server

	TxStatus byte
	// contains filtered or unexported fields
}

Conn is a PostgreSQL connection handle. It is not safe for concurrent usage. Use ConnPool to manage access to multiple database connections from multiple goroutines.

func Connect

func Connect(config ConnConfig) (c *Conn, err error)

Connect establishes a connection with a PostgreSQL server using config. config.Host must be specified. config.User will default to the OS user name. Other config fields are optional.

func (*Conn) Begin

func (c *Conn) Begin() (*Tx, error)

Begin starts a transaction with the default isolation level for the current connection. To use a specific isolation level see BeginIso.

func (*Conn) BeginIso

func (c *Conn) BeginIso(isoLevel string) (*Tx, error)

BeginIso starts a transaction with isoLevel as the transaction isolation level.

Valid isolation levels (and their constants) are:

serializable (pgx.Serializable)
repeatable read (pgx.RepeatableRead)
read committed (pgx.ReadCommitted)
read uncommitted (pgx.ReadUncommitted)

func (*Conn) CauseOfDeath

func (c *Conn) CauseOfDeath() error

func (*Conn) Close

func (c *Conn) Close() (err error)

Close closes a connection. It is safe to call Close on a already closed connection.

func (*Conn) Deallocate

func (c *Conn) Deallocate(name string) (err error)

Deallocate released a prepared statement

func (*Conn) Exec

func (c *Conn) Exec(sql string, arguments ...interface{}) (commandTag CommandTag, err error)

Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments will be sanitized before being interpolated into sql strings. arguments should be referenced positionally from the sql string as $1, $2, etc.

func (*Conn) IsAlive

func (c *Conn) IsAlive() bool

func (*Conn) Listen

func (c *Conn) Listen(channel string) (err error)

Listen establishes a PostgreSQL listen/notify to channel

func (*Conn) Prepare

func (c *Conn) Prepare(name, sql string) (ps *PreparedStatement, err error)

Prepare creates a prepared statement with name and sql. sql can contain placeholders for bound parameters. These placeholders are referenced positional as $1, $2, etc.

func (*Conn) Query

func (c *Conn) Query(sql string, args ...interface{}) (*Rows, error)

Query executes sql with args. If there is an error the returned *Rows will be returned in an error state. So it is allowed to ignore the error returned from Query and handle it in *Rows.

func (*Conn) QueryRow

func (c *Conn) QueryRow(sql string, args ...interface{}) *Row

QueryRow is a convenience wrapper over Query. Any error that occurs while querying is deferred until calling Scan on the returned *Row. That *Row will error with ErrNoRows if no rows are returned.

func (*Conn) WaitForNotification

func (c *Conn) WaitForNotification(timeout time.Duration) (*Notification, error)

WaitForNotification waits for a PostgreSQL notification for up to timeout. If the timeout occurs it returns pgx.ErrNotificationTimeout

type ConnConfig

type ConnConfig struct {
	Host      string // host (e.g. localhost) or path to unix domain socket directory (e.g. /private/tmp)
	Port      uint16 // default: 5432
	Database  string
	User      string // default: OS user name
	Password  string
	TLSConfig *tls.Config // config for TLS connection -- nil disables TLS
	Logger    log.Logger
}

ConnConfig contains all the options used to establish a connection.

func ParseURI

func ParseURI(uri string) (ConnConfig, error)

ParseURI parses a database URI into ConnConfig

type ConnPool

type ConnPool struct {
	// contains filtered or unexported fields
}

func NewConnPool

func NewConnPool(config ConnPoolConfig) (p *ConnPool, err error)

NewConnPool creates a new ConnPool. config.ConnConfig is passed through to Connect directly.

func (*ConnPool) Acquire

func (p *ConnPool) Acquire() (c *Conn, err error)

Acquire takes exclusive use of a connection until it is released.

func (*ConnPool) Begin

func (p *ConnPool) Begin() (*Tx, error)

Begin acquires a connection and begins a transaction on it. When the transaction is closed the connection will be automatically released.

func (*ConnPool) BeginIso

func (p *ConnPool) BeginIso(iso string) (*Tx, error)

BeginIso acquires a connection and begins a transaction in isolation mode iso on it. When the transaction is closed the connection will be automatically released.

func (*ConnPool) Close

func (p *ConnPool) Close()

Close ends the use of a connection pool by closing all underlying connections.

func (*ConnPool) Exec

func (p *ConnPool) Exec(sql string, arguments ...interface{}) (commandTag CommandTag, err error)

Exec acquires a connection, delegates the call to that connection, and releases the connection

func (*ConnPool) Query

func (p *ConnPool) Query(sql string, args ...interface{}) (*Rows, error)

Query acquires a connection and delegates the call to that connection. When *Rows are closed, the connection is released automatically.

func (*ConnPool) QueryRow

func (p *ConnPool) QueryRow(sql string, args ...interface{}) *Row

QueryRow acquires a connection and delegates the call to that connection. The connection is released automatically after Scan is called on the returned *Row.

func (*ConnPool) Release

func (p *ConnPool) Release(conn *Conn)

Release gives up use of a connection.

func (*ConnPool) Stat

func (p *ConnPool) Stat() (s ConnPoolStat)

Stat returns connection pool statistics

type ConnPoolConfig

type ConnPoolConfig struct {
	ConnConfig
	MaxConnections int               // max simultaneous connections to use, default 5, must be at least 2
	AfterConnect   func(*Conn) error // function to call on every new connection
}

type ConnPoolStat

type ConnPoolStat struct {
	MaxConnections       int // max simultaneous connections to use
	CurrentConnections   int // current live connections
	AvailableConnections int // unused live connections
}

type FieldDescription

type FieldDescription struct {
	Name            string
	Table           Oid
	AttributeNumber int16
	DataType        Oid
	DataTypeSize    int16
	Modifier        int32
	FormatCode      int16
}

type Notification

type Notification struct {
	Pid     int32  // backend pid that sent the notification
	Channel string // channel from which notification was received
	Payload string
}

type NullBool

type NullBool struct {
	Bool  bool
	Valid bool // Valid is true if Bool is not NULL
}

NullBool represents an bool that may be null. NullBool implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullBool) EncodeBinary

func (n NullBool) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullBool) EncodeText

func (n NullBool) EncodeText() (string, byte, error)

func (*NullBool) Scan

func (n *NullBool) Scan(vr *ValueReader) error

type NullFloat32

type NullFloat32 struct {
	Float32 float32
	Valid   bool // Valid is true if Float32 is not NULL
}

NullFloat32 represents an float4 that may be null. NullFloat32 implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullFloat32) EncodeBinary

func (n NullFloat32) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullFloat32) EncodeText

func (n NullFloat32) EncodeText() (string, byte, error)

func (*NullFloat32) Scan

func (n *NullFloat32) Scan(vr *ValueReader) error

type NullFloat64

type NullFloat64 struct {
	Float64 float64
	Valid   bool // Valid is true if Float64 is not NULL
}

NullFloat64 represents an float8 that may be null. NullFloat64 implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullFloat64) EncodeBinary

func (n NullFloat64) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullFloat64) EncodeText

func (n NullFloat64) EncodeText() (string, byte, error)

func (*NullFloat64) Scan

func (n *NullFloat64) Scan(vr *ValueReader) error

type NullInt16

type NullInt16 struct {
	Int16 int16
	Valid bool // Valid is true if Int16 is not NULL
}

NullInt16 represents an smallint that may be null. NullInt16 implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullInt16) EncodeBinary

func (n NullInt16) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullInt16) EncodeText

func (n NullInt16) EncodeText() (string, byte, error)

func (*NullInt16) Scan

func (n *NullInt16) Scan(vr *ValueReader) error

type NullInt32

type NullInt32 struct {
	Int32 int32
	Valid bool // Valid is true if Int64 is not NULL
}

NullInt32 represents an integer that may be null. NullInt32 implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullInt32) EncodeBinary

func (n NullInt32) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullInt32) EncodeText

func (n NullInt32) EncodeText() (string, byte, error)

func (*NullInt32) Scan

func (n *NullInt32) Scan(vr *ValueReader) error

type NullInt64

type NullInt64 struct {
	Int64 int64
	Valid bool // Valid is true if Int64 is not NULL
}

NullInt64 represents an bigint that may be null. NullInt64 implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullInt64) EncodeBinary

func (n NullInt64) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullInt64) EncodeText

func (n NullInt64) EncodeText() (string, byte, error)

func (*NullInt64) Scan

func (n *NullInt64) Scan(vr *ValueReader) error

type NullString

type NullString struct {
	String string
	Valid  bool // Valid is true if Int64 is not NULL
}

NullString represents an string that may be null. NullString implements the Scanner and TextEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullString) EncodeText

func (s NullString) EncodeText() (string, byte, error)

func (*NullString) Scan

func (s *NullString) Scan(vr *ValueReader) error

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

NullTime represents an bigint that may be null. NullTime implements the Scanner, TextEncoder, and BinaryEncoder interfaces so it may be used both as an argument to Query[Row] and a destination for Scan for prepared and unprepared queries.

If Valid is false then the value is NULL.

func (NullTime) EncodeBinary

func (n NullTime) EncodeBinary(w *WriteBuf, oid Oid) error

func (NullTime) EncodeText

func (n NullTime) EncodeText() (string, byte, error)

func (*NullTime) Scan

func (n *NullTime) Scan(vr *ValueReader) error

type Oid

type Oid int32

type PgError

type PgError struct {
	Severity string
	Code     string
	Message  string
}

func (PgError) Error

func (self PgError) Error() string

type PreparedStatement

type PreparedStatement struct {
	Name              string
	FieldDescriptions []FieldDescription
	ParameterOids     []Oid
}

type ProtocolError

type ProtocolError string

func (ProtocolError) Error

func (e ProtocolError) Error() string

type QueryArgs

type QueryArgs []interface{}

QueryArgs is a container for arguments to an SQL query. It is helpful when building SQL statements where the number of arguments is variable.

func (*QueryArgs) Append

func (qa *QueryArgs) Append(v interface{}) string

Append adds a value to qa and returns the placeholder value for the argument. e.g. $1, $2, etc.

type Row

type Row Rows

Row is a convenience wrapper over Rows that is returned by QueryRow.

func (*Row) Scan

func (r *Row) Scan(dest ...interface{}) (err error)

Scan reads the values from the row into dest values positionally. dest can include pointers to core types and the Scanner interface. If no rows were found it returns ErrNoRows. If multiple rows are returned it ignores all but the first.

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows is the result set returned from *Conn.Query. Rows must be closed before the *Conn can be used again. Rows are closed by explicitly calling Close(), calling Next() until it returns false, or when a fatal error occurs.

func (*Rows) Close

func (rows *Rows) Close()

Close closes the rows, making the connection ready for use again. It is not usually necessary to call Close explicitly because reading all returned rows with Next automatically closes Rows. It is safe to call Close after rows is already closed.

func (*Rows) Err

func (rows *Rows) Err() error

func (*Rows) Fatal

func (rows *Rows) Fatal(err error)

Fatal signals an error occurred after the query was sent to the server. It closes the rows automatically.

func (*Rows) FieldDescriptions

func (rows *Rows) FieldDescriptions() []FieldDescription

func (*Rows) Next

func (rows *Rows) Next() bool

Next prepares the next row for reading. It returns true if there is another row and false if no more rows are available. It automatically closes rows when all rows are read.

func (*Rows) Scan

func (rows *Rows) Scan(dest ...interface{}) (err error)

Scan reads the values from the current row into dest values positionally. dest can include pointers to core types and the Scanner interface.

func (*Rows) Values

func (rows *Rows) Values() ([]interface{}, error)

Values returns an array of the row values

type Scanner

type Scanner interface {
	// Scan MUST check r.Type().DataType and r.Type().FormatCode before decoding.
	// It should not assume that it was called on the type of value.
	Scan(r *ValueReader) error
}

Scanner is an interface used to decode values from the PostgreSQL server.

type SerializationError

type SerializationError string

func (SerializationError) Error

func (e SerializationError) Error() string

type TextEncoder

type TextEncoder interface {
	// EncodeText returns the value encoded into a string. status must be
	// NullText if the value is NULL, UnsafeText if the value should be quoted
	// and escaped, or SafeText if the value should not be quoted.
	EncodeText() (val string, status byte, err error)
}

TextEncoder is an interface used to encode values in text format for transmission to the PostgreSQL server. It is used by unprepared queries and for prepared queries when the type does not implement BinaryEncoder

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx represents a database transaction.

All Tx methods return ErrTxClosed if Commit or Rollback has already been called on the Tx.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction

func (*Tx) Exec

func (tx *Tx) Exec(sql string, arguments ...interface{}) (commandTag CommandTag, err error)

Exec delegates to the underlying *Conn

func (*Tx) Query

func (tx *Tx) Query(sql string, args ...interface{}) (*Rows, error)

Query delegates to the underlying *Conn

func (*Tx) QueryRow

func (tx *Tx) QueryRow(sql string, args ...interface{}) *Row

QueryRow delegates to the underlying *Conn

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rolls back the transaction. Rollback will return ErrTxClosed if the Tx is already closed, but is otherwise safe to call multiple times. Hence, a defer tx.Rollback() is safe even if tx.Commit() will be called first in a non-error condition.

type ValueReader

type ValueReader struct {
	// contains filtered or unexported fields
}

ValueReader is used by the Scanner interface to decode values.

func (*ValueReader) Err

func (r *ValueReader) Err() error

Err returns any error that the ValueReader has experienced

func (*ValueReader) Fatal

func (r *ValueReader) Fatal(err error)

Fatal tells r that a Fatal error has occurred

func (*ValueReader) Len

func (r *ValueReader) Len() int32

Len returns the number of unread bytes

func (*ValueReader) ReadByte

func (r *ValueReader) ReadByte() byte

func (*ValueReader) ReadBytes

func (r *ValueReader) ReadBytes(count int32) []byte

ReadBytes reads count bytes and returns as []byte

func (*ValueReader) ReadInt16

func (r *ValueReader) ReadInt16() int16

func (*ValueReader) ReadInt32

func (r *ValueReader) ReadInt32() int32

func (*ValueReader) ReadInt64

func (r *ValueReader) ReadInt64() int64

func (*ValueReader) ReadOid

func (r *ValueReader) ReadOid() Oid

func (*ValueReader) ReadString

func (r *ValueReader) ReadString(count int32) string

ReadString reads count bytes and returns as string

func (*ValueReader) Type

func (r *ValueReader) Type() *FieldDescription

Type returns the *FieldDescription of the value

type WriteBuf

type WriteBuf struct {
	// contains filtered or unexported fields
}

WrifeBuf is used build messages to send to the PostgreSQL server. It is used by the BinaryEncoder interface when implementing custom encoders.

func (*WriteBuf) WriteByte

func (wb *WriteBuf) WriteByte(b byte)

func (*WriteBuf) WriteBytes

func (wb *WriteBuf) WriteBytes(b []byte)

func (*WriteBuf) WriteCString

func (wb *WriteBuf) WriteCString(s string)

func (*WriteBuf) WriteInt16

func (wb *WriteBuf) WriteInt16(n int16)

func (*WriteBuf) WriteInt32

func (wb *WriteBuf) WriteInt32(n int32)

func (*WriteBuf) WriteInt64

func (wb *WriteBuf) WriteInt64(n int64)

Directories

Path Synopsis
examples
Package stdlib is the compatibility layer from pgx to database/sql.
Package stdlib is the compatibility layer from pgx to database/sql.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL