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

pgerror

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pgerror provides utilities for working with PostgreSQL errors.

Index

Constants

View Source
const (
	// CodeUniqueViolation is the PostgreSQL error code for "unique_violation".
	CodeUniqueViolation = "23505"

	// CodeUndefinedTable is the PostgreSQL error code for "undefined_table".
	CodeUndefinedTable = "42P01"
)

https://www.postgresql.org/docs/11/errcodes-appendix.html

Variables

This section is empty.

Functions

func Is

func Is(err error, codes ...string) bool

Is returns true if err is a PostgreSQL error with one of the given codes.

func Retry

func Retry(
	ctx context.Context,
	db *sql.DB,
	fn func(*sql.Tx) error,
	codes ...string,
) error

Retry executes fn within a transaction, retrying it if the error is one of the given codes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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