Documentation ¶
Overview ¶
Package keys provides utilities to manipulate key strings.
Index ¶
- func IsArrayLen(key string) (string, bool)
- func ParseArrayElement(key string) (string, []int)
- type Replacer
- type ReplacerFunc
- func CamelCaseReplacer() ReplacerFunc
- func CamelCaseSepReplacer(sep string) ReplacerFunc
- func ChainReplacer(rr ...ReplacerFunc) ReplacerFunc
- func LowerCamelCaseReplacer() ReplacerFunc
- func LowerCamelCaseSepReplacer(sep string) ReplacerFunc
- func LowerCaseReplacer() ReplacerFunc
- func NullReplacer() ReplacerFunc
- func PrefixReplacer(prefix string) ReplacerFunc
- func StringReplacer(old, new string) ReplacerFunc
- func UpperCaseReplacer() ReplacerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsArrayLen ¶
IsArrayLen determines if the key corresponds to an array length. i.e. is of the form a[]. If so IsArrayLen returns true and the name of the array.
func ParseArrayElement ¶
ParseArrayElement determines if the key corresponds to an array element. i.e. is of the form a[i]. Returns the name of the array and the a list of indicies into the array.
Types ¶
type ReplacerFunc ¶
ReplacerFunc is a func that implements a string replacement.
func CamelCaseReplacer ¶
func CamelCaseReplacer() ReplacerFunc
CamelCaseReplacer is a replacer that that forces keys to camel case, so each word begins with a capital letter. Words are separated by the default separator - ".".
func CamelCaseSepReplacer ¶
func CamelCaseSepReplacer(sep string) ReplacerFunc
CamelCaseSepReplacer is a replacer that that forces keys to camel case, so each word begins with a capital letter. Words are separated by the provided separator.
func ChainReplacer ¶
func ChainReplacer(rr ...ReplacerFunc) ReplacerFunc
ChainReplacer returns a replacer that applies a list of replacers, in order.
func LowerCamelCaseReplacer ¶
func LowerCamelCaseReplacer() ReplacerFunc
LowerCamelCaseReplacer is a replacer that that forces keys to camel case, so each word begins with a capital letter, except the first word which is all lower case. Words are separated by the default separator - ".".
func LowerCamelCaseSepReplacer ¶
func LowerCamelCaseSepReplacer(sep string) ReplacerFunc
LowerCamelCaseSepReplacer is a replacer that that forces keys to camel case, so each word begins with a capital letter, except the first word which is all lower case. Words are separated by the provided separator.
func LowerCaseReplacer ¶
func LowerCaseReplacer() ReplacerFunc
LowerCaseReplacer is a replacer that that forces keys to lower case.
func NullReplacer ¶
func NullReplacer() ReplacerFunc
NullReplacer is a replacer that leaves a key unchanged. This can be used to override the mapping in Getters that assume a default mapping if none (Replacer(nil)) is provided.
func PrefixReplacer ¶
func PrefixReplacer(prefix string) ReplacerFunc
PrefixReplacer adds a prefix to keys. This can be used to logically move the root of a Getter to a node of the config space.
func StringReplacer ¶
func StringReplacer(old, new string) ReplacerFunc
StringReplacer replaces one string in the key with another. The ols is replaced with the new using strings.Replace. This is typically used to replace tier separators, e.g. "." in config space with "_" in env space, but can also be used for arbitrary substitutions.
func UpperCaseReplacer ¶
func UpperCaseReplacer() ReplacerFunc
UpperCaseReplacer forces keys to upper case.
func (ReplacerFunc) Replace ¶
func (r ReplacerFunc) Replace(key string) string
Replace calls the ReplacerFunc to perform the map.