koanfutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package koanfutil provides utilities for koanf configuration loading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileResolver

func FileResolver(k *koanf.Koanf) koanf.Provider

FileResolver returns a koanf.Provider that resolves file:// URIs in string values to their file contents.

Usage:

k := koanf.New(".")
k.Load(file.Provider("config.toml"), toml.Parser())
k.Load(koanfutil.FileResolver(k), nil)  // Resolves file:// URIs

String values like "file:///etc/secrets/password" are replaced with the trimmed contents of /etc/secrets/password. Returns error if any file:// URI cannot be resolved.

func WithDefaults

func WithDefaults[T any](defaults T) koanf.Provider

WithDefaults returns a koanf.Provider that provides default values from a struct. The struct fields must have `koanf` tags to define the key names.

Usage:

k := koanf.New(".")
k.Load(koanfutil.WithDefaults(postgres.DefaultConfig()), nil)
k.Load(file.Provider("config.toml"), toml.Parser())

Types

This section is empty.

Jump to

Keyboard shortcuts

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