Documentation ¶
Overview ¶
Package env implements functions for turning config values that are parameterized by the environment string or environment variables into unambiguous, concrete files, paths, and packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateKey ¶
ValidateKey will determine if a key can be split into valid regexp fields.
Types ¶
type Environment ¶
type Environment []string
An Environment is a sequence of fields specified by an environment string.
func NewEnvironment ¶
func NewEnvironment(env string) Environment
NewEnvironment returns an Environment from an environment string `env`. The environment string has fields separated by spaces.
func (Environment) Matches ¶
func (env Environment) Matches(s string) bool
Matches returns if the passed string s matches the environment as a bool.
func (Environment) Select ¶
func (env Environment) Select(keys []string) (key string, fields []string)
Select determines which key in a slice of strings `keys` matches the environment. A key is a string of regular expressions that may match any field in the environment separated by spaces. The first key that matches the environment will be returned, or an empty string otherwise. The fields that matched the key in the order that they were matched are also returned as a slice.
Note that it's possible for the empty returned string to actually be the matched key itself. This is because an entirely whitespace key acts as a wildcard that matches if no other non-wildcard keys match.
type Match ¶
type Match struct {
// contains filtered or unexported fields
}
A Match is the result of an environment matching a key. The subgroups in the match are used to replace the contents of other strings.