Documentation ¶
Overview ¶
Package text provides various utilities for working with text. Most APIs have both string and []byte versions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandVariables ¶
ExpandVariables replaces ${var} in the byte slice based on the mapping function. The returned byte slice is a copy of src with the replacements made, src is not modified. If src contains no variables, src is returned as is.
Types ¶
type VariableMapper ¶
type VariableMapper struct {
// contains filtered or unexported fields
}
VariableMapper can be used to expand variables with ExpandVariables or ExpandVariablesString. It records any missing variables.
func NewVariableMapper ¶
func NewVariableMapper(vars map[string]string) *VariableMapper
NewVariableMapper creates a new VariableMapper that uses vars as the values for expanded variables.
func (*VariableMapper) Map ¶
func (vm *VariableMapper) Map(name string) string
Map maps a variable name to its value. It can be passed to ExpandVariables or ExpandVariablesString.
func (*VariableMapper) Missing ¶
func (vm *VariableMapper) Missing() []string
Missing returns all missing variables that were encountered in order. A missing variable is only included once, duplicates are removed.