Documentation
¶
Index ¶
Constants ¶
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 ¶
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
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
}