Env
The Env registry provides functions for accessing and managing environment variables, enabling dynamic configuration of your applications based on the runtime environment.
env
The function retrieves the value of a specified environment variable from the system.
Signature
Env(key string) string
{{ env "INVALID" }} // Output: ""
{{ "PATH" | env }} // Output(will be different): "/usr/bin:/bin:/usr/sbin:/sbin"
expandEnv
The function replaces occurrences of ${var}
or $var
in a string with the corresponding values from the current environment variables.
Signature
ExpandEnv(str string) string
{{ "Path is $PATH" | expandEnv }} // Output(will be different): "Path is /usr/bin:/bin:/usr/sbin:/sbin"
Last updated