Documentation
¶
Overview ¶
Package envsubst expands ${VAR} and $VAR references in strings against a caller-supplied lookup. It mirrors the syntax of os.Expand (both braced ${VAR} and bare $VAR forms, with VAR = [A-Za-z_][A-Za-z0-9_]*), but differs from the standard library in two ways that callers in this repo rely on:
- An unset variable (lookup returns ok=false) is left as the literal reference (${"${VAR}"} or $VAR) rather than replaced with the empty string. This lets callers surface "VAR was not set" instead of silently substituting nothing.
- Expand returns the sorted list of variable names that were unset, so the caller can report them. (os.Expand's mapper has no ok return and thus cannot distinguish "empty value" from "unset".)
Use ExpandOS for the common case of resolving against os.LookupEnv with no interest in the unset list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expand ¶
Expand replaces ${VAR} and $VAR references in s using lookup to resolve each name. A name that lookup reports as unset (ok=false) is left as the original literal reference and is included in the returned missing slice (sorted, de-duplicated). The expanded string and the missing list are returned.
lookup mirrors os.LookupEnv's contract: returning (value, true) substitutes value (which may itself be empty); returning (_, false) marks the name unset.
func ExpandOS ¶
ExpandOS is a convenience wrapper around Expand that resolves references against the process environment (os.LookupEnv) and returns only the expanded string. Unset variables are left as their literal reference.
Types ¶
This section is empty.