config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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