config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: LGPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	InfoLevel  = "info"
	DebugLevel = "debug"
	WarnLevel  = "warn"
)
View Source
const (
	ExtYaml        = "YAML"
	ExtJson        = "JSON"
	ExtUnsupported = "unsupported"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgDir

type CfgDir struct {
	Path string
}

CfgDir enables config to be loaded from a conf.d directory, note that directory values will take precedence over single file

type CfgFile

type CfgFile struct {
	Path string
}

CfgFile enables config to be loaded from a single file

type Config

type Config struct {
	// contains filtered or unexported fields
}

func Load

func Load(opts ...any) (*Config, error)

func (*Config) Debug

func (c *Config) Debug(msg string)

func (*Config) GetString

func (c *Config) GetString(fieldName string) (string, error)

func (*Config) Subset

func (c *Config) Subset(key string) *Config

Subset returns a config that only handles a subset of the overall config

func (*Config) Unmarshal

func (c *Config) Unmarshal(payload any) error

Unmarshal will recursively navigate the struct using reflection and populate the fields based on the flattened config representation

type Defaults

type Defaults struct {
	Item any
}

Defaults enables to provide a set of default values to the configuration

type EnvVar

type EnvVar struct {
	Prefix string
}

EnvVar enables to load config using an env vars note that Envs will take precedence over file persisted values

type Unmarshal

type Unmarshal struct {
	Item any
}

Unmarshal is an implicit call to unmarshal when calling the Load function if you intend to simply load + unmarshal, with this item you can simplify one function call

type Writer

type Writer struct {
	Fn func(level, msg string)
}

Writer allows to print information about what the config is doing it will write two levels info and debug

Jump to

Keyboard shortcuts

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