Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
// contains filtered or unexported fields
}
ConfigFile represents an embedded .yaml file, that holds the configuration object.
func NewConfig ¶ added in v1.0.0
func NewConfig(env string, file []byte) ConfigFile
NewConfig creates a new ConfigFile object, targeted to a specific environment. To create a global configuration file, leave the environment empty.
type Loader ¶ added in v1.1.0
type Loader[T any] struct { // contains filtered or unexported fields }
Loader is an interface used to load configuration files using environment information.
func NewLoader ¶ added in v1.1.0
func NewLoader[T any](config LoaderConfig) *Loader[T]
NewLoader creates a new Loader object.
func (*Loader[T]) Load ¶ added in v1.1.0
func (loader *Loader[T]) Load(files ...ConfigFile) (T, error)
func (*Loader[T]) MustLoad ¶ added in v1.1.0
func (loader *Loader[T]) MustLoad(files ...ConfigFile) T
type LoaderConfig ¶ added in v1.1.0
type LoaderConfig struct {
// Deserializer used to unmarshal the file content. Defaults to json.Unmarshal.
Deserializer func(data []byte, dst any) error
// If true, env variable declarations are automatically interpolated with their
// actual value from the environment.
ExpandEnv bool
// The current environment. Uses the value in "ENV" variable by default.
Env string
}
LoaderConfig sets a file loader.
Click to show internal directories.
Click to hide internal directories.