Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCircularDependency = errors.New("circular dependency detected")
Functions ¶
func ResolveDependants ¶ added in v1.3.0
func ResolveDependants[Mod comparable, Deps any](mods map[Mod][]Deps, deps map[Mod][]Mod) (map[Mod][]Deps, error)
ResolveDependants unwraps a flat list of dependencies, given a map of interdependent modules. It also prevents circular dependencies.
E.g.:
mod1 has dep1 and dep2 mod2 has dep3 and inherited from mod1
The algorithm will resolve the following dependencies:
mod1 -> dep1, dep2 mod2 -> dep3, dep1, dep2
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.