package pgimport ()// Connect connects to a database using provided options.//// The returned DB is safe for concurrent use by multiple goroutines// and maintains its own connection pool.func ( *Options) *DB { .init()returnnewDB(context.Background(), &baseDB{opt: ,pool: newConnPool(),fmter: orm.NewFormatter(), }, )}func ( context.Context, *baseDB) *DB { := &DB{baseDB: .clone(),ctx: , } .baseDB.db = return}// DB is a database handle representing a pool of zero or more// underlying connections. It's safe for concurrent use by multiple// goroutines.typeDBstruct { *baseDBctxcontext.Context}var _ orm.DB = (*DB)(nil)func ( *DB) () string {returnfmt.Sprintf("DB<Addr=%q%s>", .opt.Addr, .fmter)}// Options returns read-only Options that were used to connect to the DB.func ( *DB) () *Options {return .opt}// Context returns DB context.func ( *DB) () context.Context {return .ctx}// WithContext returns a copy of the DB that uses the ctx.func ( *DB) ( context.Context) *DB {returnnewDB(, .baseDB)}// WithTimeout returns a copy of the DB that uses d as the read/write timeout.func ( *DB) ( time.Duration) *DB {returnnewDB(.ctx, .baseDB.WithTimeout())}// WithParam returns a copy of the DB that replaces the param with the value// in queries.func ( *DB) ( string, interface{}) *DB {returnnewDB(.ctx, .baseDB.WithParam(, ))}// Listen listens for notifications sent with NOTIFY command.func ( *DB) ( context.Context, ...string) *Listener { := &Listener{db: , } .init() _ = .Listen(, ...)return}// Conn represents a single database connection rather than a pool of database// connections. Prefer running queries from DB unless there is a specific// need for a continuous single database connection.//// A Conn must call Close to return the connection to the database pool// and may do so concurrently with a running query.//// After a call to Close, all operations on the connection fail.typeConnstruct { *baseDBctxcontext.Context}var _ orm.DB = (*Conn)(nil)// Conn returns a single connection from the connection pool.// Queries run on the same Conn will be run in the same database session.//// Every Conn must be returned to the database pool after use by// calling Conn.Close.func ( *DB) () *Conn {returnnewConn(.ctx, .baseDB.withPool(pool.NewStickyConnPool(.pool)))}func ( context.Context, *baseDB) *Conn { := &Conn{baseDB: ,ctx: , } .baseDB.db = return}// Context returns DB context.func ( *Conn) () context.Context {if .ctx != nil {return .ctx }returncontext.Background()}// WithContext returns a copy of the DB that uses the ctx.func ( *Conn) ( context.Context) *Conn {returnnewConn(, .baseDB)}// WithTimeout returns a copy of the DB that uses d as the read/write timeout.func ( *Conn) ( time.Duration) *Conn {returnnewConn(.ctx, .baseDB.WithTimeout())}// WithParam returns a copy of the DB that replaces the param with the value// in queries.func ( *Conn) ( string, interface{}) *Conn {returnnewConn(.ctx, .baseDB.WithParam(, ))}
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)