loader

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 4 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 Redis connection parameters from the koanf env singleton (keys: redis.clusters, redis.database, redis.password) and initialises the package-level default client via redis.InitDefault.

go-redis creates the client without establishing a connection (lazy dial), so LoadFromEnv always returns nil — connectivity errors are discovered on the first real command instead.

redis.InitDefault uses sync.Once: only the first call takes effect. After LoadFromEnv returns, redis.Default() is non-nil regardless of whether the Redis server is reachable.

package main

import (
	"fmt"

	"github.com/phcp-tech/common-library-golang/redis"
	"github.com/phcp-tech/common-library-golang/redis/loader"
)

func main() {
	err := loader.LoadFromEnv()
	fmt.Println(err)                    // <nil> — go-redis is lazy, no immediate connect
	fmt.Println(redis.Default() != nil) // true  — singleton registered
}
Output:
<nil>
true

Types

This section is empty.

Jump to

Keyboard shortcuts

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