config

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config provides minimal helpers for loading application configuration files. It intentionally does not implement overlay, merging, validation, profile chains, env interpolation, or file watching — those are domain-specific policies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find(filename, startDir string) string

Find walks up from startDir looking for filename. It stops at the filesystem root. Returns the absolute path of the first regular file found, or "" when none exists. An empty startDir uses the current working directory.

func Load

func Load(dst any, paths ...string) error

Load reads each path in order and decodes into dst. Fields present in later files override fields present in earlier files; fields absent from later files are left untouched. Unknown keys are rejected. Format is selected by extension: .yaml/.yml (yaml.v3), .json (encoding/json). Any other extension returns xerr.BadRequest. An empty path is skipped. An empty file is a no-op.

func LoadFromDir

func LoadFromDir(dst any, filename, startDir string) error

LoadFromDir combines Find and Load. It returns nil when no file named filename exists anywhere between startDir and the filesystem root — callers use this when "no config file" means "keep defaults". A present-but-unreadable or malformed file still returns an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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