config

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T any](c *T, opts ...Option) error

Load reads configuration from various sources and unmarshals it into a given struct.

It looks for configuration in the following order (later overrides earlier): 1. Local file, if `WithLocalYAML` is provided. 2. `.env` file in the current working directory. 3. Environment variables.

If any of the above sources result in an error (other than `os.ErrNotExist`), it will be returned.

If a source results in `os.ErrNotExist`, it will be skipped.

The final configuration will be unmarshaled into the given struct. If unmarshaling fails, an error will be returned.

Types

type Option

type Option func(*options)

func WithLocalYAML

func WithLocalYAML(path string) Option

WithLocalYAML specifies a path to a local YAML file to load config from. If the file does not exist, an error is not returned.

Jump to

Keyboard shortcuts

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