config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNoKey          = utils.Error("Config key does not exist")
	ErrNotImplemented = utils.Error("Config method or type not implemented")
	ErrInvalidType    = utils.Error("Invalid destination type")
	ErrInvalidDefault = utils.Error("Invalid default value")
	ErrRemovedKey     = utils.Error("Removed config key present")
	ErrInvalidKeyPath = utils.Error("Invalid config key path")
)

Variables

This section is empty.

Functions

func CheckRemovedKeys added in v0.13.0

func CheckRemovedKeys(p ConfigProvider, removed map[string]string) error

CheckRemovedKeys returns an error wrapping ErrRemovedKey if the configuration held by p still contains any of the removed or renamed keys.

Keys of removed are dotted paths relative to p (pass the root provider for root-relative paths). Matching ignores case in every segment, like encoding/json; the error reports each key as spelled in the config. Values of removed are replacement hints included in the error message. Only providers whose Get can fill a map[string]json.RawMessage (the JSON provider) are supported; others yield an error wrapping ErrNotImplemented.

func StrOrFile

func StrOrFile(value string) string

StrOrFile attempts to identify a valid file path from value; if value starts with "/" or "./" it will attempt to read the file contents and return it instead; if the file contains an extra \n it will be trimmed. If no file is found (either value does not start with "/" or "./", or file does not exist), value is returned.

func StrOrFileIfExists added in v0.8.7

func StrOrFileIfExists(value string) string

StrOrFileIfExists reads and returns the contents of value if it points to an existing regular file. If value is not an existing file, the original string is returned unchanged.

Types

type ConfigProvider added in v0.6.0

type ConfigProvider interface {
	Get(dest interface{}) error
	GetKey(key string, dest interface{}) error
	GetStringKey(key string) (string, error)
	GetBoolKey(key string) (bool, error)
	GetIntKey(key string) (int, error)
	GetFloat64Key(key string) (float64, error)
	GetSliceKey(key, separator string) ([]string, error)
	GetConfigNode(key string) (ConfigProvider, error)
	KeyExists(key string) bool
	KeyListExists(keys []string) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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