Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentSchemaVersion

func CurrentSchemaVersion(ctx context.Context, db *sql.DB) (int64, error)

func EnforceForwardOnly

func EnforceForwardOnly(ctx context.Context, db *sql.DB, newVersion int64) error

func EnsureSchemaVersionTable

func EnsureSchemaVersionTable(ctx context.Context, db *sql.DB) error

func Open

func Open(cfg Config) (*sql.DB, error)

func UpdateSchemaVersion

func UpdateSchemaVersion(ctx context.Context, db *sql.DB, newVersion int64) error

func WithTx

func WithTx(ctx context.Context, db *sql.DB, opts TxOptions, fn TxFunc) error

func WithTxDefault

func WithTxDefault(ctx context.Context, db *sql.DB, fn TxFunc) error

WithTxDefault runs a transaction using default isolation level and read-write mode.

Types

type Config

type Config struct {
	DSN string

	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration

	PingTimeout time.Duration
}

type TxFunc

type TxFunc func(ctx context.Context, tx *sql.Tx) error

type TxOptions

type TxOptions struct {
	Isolation sql.IsolationLevel
	ReadOnly  bool
}

Jump to

Keyboard shortcuts

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