config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig[T DefaultableAndValidatable](cfg T, configDir, configFileName string, defaultConfig []byte) error

LoadConfig takes a filepath relative to the config directory (usually just a filename) and tries to load the config from there. If the file doesn't exist, it takes the given defaults instead and also writes them to the config directory. After loading, the config is defaulted and then validated. Arguments: - cfg: The config struct to load the config into. Must be a pointer (will be passed into yaml.Unmarshal). - configDir: The directory where the config file is located. - configFileName: The name of the config file. - defaultConfig: The default config as []byte.

Types

type DefaultableAndValidatable

type DefaultableAndValidatable interface {
	// Default sets the default values for the config.
	Default() error
	// Validate validates the config.
	Validate() error
}

Jump to

Keyboard shortcuts

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