loader

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromEnv added in v0.1.9

func LoadFromEnv() error
Example

ExampleLoadFromEnv shows the typical call-site pattern for LoadFromEnv. It reads PostgreSQL connection parameters from the koanf env singleton (keys: db.host, db.port, db.name, db.schema, db.username, db.password, …) and initialises the package-level default pool via postgres.InitDefault.

LoadFromEnv performs an eager connectivity check: if the database is unreachable the error is returned immediately so the application can fail fast at startup rather than on the first real query.

postgres.InitDefault uses sync.Once — only the first call in a process takes effect. Subsequent calls (including calls from other tests in this binary) are no-ops and return nil. For this reason the example does not assert the return value: its primary purpose is to document the call site pattern.

package main

import (
	"github.com/phcp-tech/common-library-golang/dbsqlc/postgres/loader"
)

func main() {
	err := loader.LoadFromEnv()
	// err is non-nil on first call with unreachable DB;
	// nil on subsequent calls (sync.Once no-op).
	_ = err
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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