db

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host              string
	Port              int
	DBName            string
	Credential        credential.Credential
	CACertificatePath string
}

Config represents the configuration needed to connect to a database.

func BuildDBConfigFromEnv

func BuildDBConfigFromEnv() (Config, error)

BuildDBConfigFromEnv builds a Config from environment variables. Port is read from PGPORT, defaulting to 30432 (the CI host-mapped port). Optional: DB_HOST, DB_NAME, DB_USER, DB_PASSWORD, DB_CA_CERT_PATH

func (*Config) BuildDSN

func (c *Config) BuildDSN() string

BuildDSN builds the Data Source Name (DSN) string for connecting to the database. User and password are URL-encoded to handle special characters such as "@", ":", "/", etc.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the Config fields are set correctly.

type ErrorChecker

type ErrorChecker interface {
	IsErrNoRows(err error) bool
	IsUniqueConstraintError(err error) bool
}

ErrorChecker abstracts database error classification.

Directories

Path Synopsis
Package testutil provides database test utilities for integration tests.
Package testutil provides database test utilities for integration tests.

Jump to

Keyboard shortcuts

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