config

package
v2.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpNew          = "configurer: new ->"
	OpUnmarshalKey = "configurer: unmarshal key ->"
	OpUnmarshal    = "configurer: unmarshal ->"
	OpOverwrite    = "configurer: overwrite ->"
	OpParseFlag    = "configurer: parse flag ->"
)

Variables

This section is empty.

Functions

func ExpandVal

func ExpandVal(s string, mapping func(string) string) string

ExpandVal replaces ${var} or $var in the string based on the mapping function. For example, os.ExpandEnv(s) is equivalent to os.Expand(s, os.Getenv).

Types

type Configurer

type Configurer interface {
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error

	// Unmarshal the config into a Struct. Make sure that the tags
	// on the fields of the structure are properly set.
	Unmarshal(out any) error

	// Overwrite used to overwrite particular values in the unmarshalled config
	Overwrite(values map[string]any) error

	// Get used to get config section
	Get(name string) any

	// Has checks if config section exists.
	Has(name string) bool

	GracefulTimeout() time.Duration

	// Version returns current version
	Version() string
}

func NewConfigurer

func NewConfigurer(version string, timeout time.Duration, options ...Option) (Configurer, error)

type Option

type Option func(*configurer)

func WithConfigType

func WithConfigType(tp string) Option

func WithFlags

func WithFlags(flags []string) Option

func WithPath

func WithPath(path string) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithReadInCfg

func WithReadInCfg(readInCfg []byte) Option

Jump to

Keyboard shortcuts

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