sqlutil

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTx

func WithTx(ctx context.Context, db *sql.DB, fn func(ctx context.Context, tx *sql.Tx) error) (err error)

WithTx executes the given function within a database transaction.

This function is reentrant. It will create nested transactions using SAVEPOINTs if needed. However, transactions are not thread-safe, so care must be used when creating goroutines inside transactions: ensure a separate context is used that does not carry the transaction with it.

Types

type PanicError added in v0.1.2

type PanicError struct {
	Cause error
}

func (*PanicError) Error added in v0.1.2

func (e *PanicError) Error() string

type RollbackError added in v0.1.2

type RollbackError struct {
	Trigger error
	Cause   error
}

func (*RollbackError) Error added in v0.1.2

func (e *RollbackError) Error() string

Jump to

Keyboard shortcuts

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