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

config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T any](i do.Injector, component, key string, cfg T) (T, error)

Load decodes the settings under key onto cfg, which carries the defaults a key no source sets keeps. component names the module in the error an absent config produces.

func Module

func Module(opts Options) app.Module

Module provides a Config layered from config.yaml, config.local.yaml and the environment.

func StaticModule

func StaticModule(settings map[string]any) app.Module

StaticModule provides a Config from dotted keys instead of files on disk, which is how a spec boots a service with settings.

Types

type Bytes

type Bytes int64

Bytes is a byte count. A config gives it as a plain number, or as a string carrying one of the binary units B, KiB, MiB and GiB, such as 128MiB.

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(text []byte) error

type Config

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

func (*Config) Unmarshal

func (c *Config) Unmarshal(key string, out any) error

Unmarshal decodes the settings under key into out and leaves fields that no file or variable sets at their existing value.

type Options

type Options struct {
	// EnvPrefix has to end in __, which keeps unrelated environment variables
	// such as SERVICE_HOST out of the settings.
	EnvPrefix string

	// File defaults to config.yaml and is overridden by <EnvPrefix>CONFIG_FILE.
	// A path either of them names has to exist, where config.yaml may be
	// missing.
	File string
}

Jump to

Keyboard shortcuts

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