Help us shape the future of Go! Take the 2026 Go Developer Survey

configurator

package module
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 5 Imported by: 0

README

Configurator

Helpers for deployment and app setup.

go get -u github.com/a-novel-kit/configurator

GitHub Actions Workflow Status codecov Go Report Card

GitHub go.mod Go version GitHub repo file or directory count GitHub code size in bytes

Coverage graph

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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