Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
FatalErrorHandler is called with a fatal error before cfger calls os.Exit. This is to allow fatal errors to be processed correctly depending on the application itself.
Functions ¶
This section is empty.
Types ¶
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
func New ¶
func New() *ConfigLoader
func (*ConfigLoader) Get ¶
func (cl *ConfigLoader) Get(key string) OptionalItem
Get gets a given key from the currently loaded configuration.
Within a key representation, a dot represents a recursion into a named object and square brackets represent an index in a named array. You could access the value "hello" using the key `alpha[0].beta` in the below example.
alpha: - beta: "hello"
func (*ConfigLoader) Load ¶
func (cl *ConfigLoader) Load(fname string) error
Load reads a YAML config file from fname and holds it in memory.
If fname cannot be found, a blank config file will be loaded instead.
func (*ConfigLoader) Required ¶
func (cl *ConfigLoader) Required(key string) OptionalItem
Required gets a given key from the currently loaded configuration and raises a fatal error if it cannot be found.
See documentation for Get for key format.
func (*ConfigLoader) WithDefault ¶
func (cl *ConfigLoader) WithDefault(key string, defaultValue any) OptionalItem
Required gets a given key from the currently loaded configuration and returns a default value if it cannot be found.
See documentation for Get for key format.
type OptionalItem ¶
type OptionalItem struct {
// contains filtered or unexported fields
}
func (OptionalItem) AsBool ¶
func (x OptionalItem) AsBool() bool
func (OptionalItem) AsInt ¶
func (x OptionalItem) AsInt() int
func (OptionalItem) AsString ¶
func (x OptionalItem) AsString() string