Documentation ¶
Overview ¶
Package text includes utilities for working with text that might contain variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsEnvVariables ¶
ContainsEnvVariables returns true if inBytes contains environment variable replace patterns.
func ContainsFunctionVariables ¶
ContainsFunctionVariables returns true if inBytes contains function variable replace patterns.
func ReplaceEnvVariables ¶
ReplaceEnvVariables will search a blob of data for the pattern `${FOO:bar}`, where `FOO` is an environment variable name and `bar` is a default value. The `bar` section (including the colon) can be left out if there is no appropriate default value for the field.
For each aforementioned pattern found in the blob the contents of the respective environment variable will be read and will replace the pattern. If the environment variable is empty or does not exist then either the default value is used or the field will be left empty.
func ReplaceFunctionVariables ¶
ReplaceFunctionVariables will search a blob of data for the pattern `${!foo}`, where `foo` is a function name.
For each aforementioned pattern found in the blob the contents of the respective function will be run and will replace the pattern.
Some functions are able to extract contents and metadata from a message, and so a message must be supplied.
Types ¶
type Message ¶
type Message interface { Get(p int) []byte GetJSON(p int) (interface{}, error) GetMetadata(key string) string IterMetadata(func(k, v string) error) error Len() int }
Message is an interface type to be given to a function interpolator, it allows the function to resolve fields and metadata from a message.