githubEdit

Env

The Env registry provides functions for accessing and managing environment variables, enabling dynamic configuration of your applications based on the runtime environment.

circle-info

You can easily import all the functions from the env registry by including the following import statement in your code

import "github.com/go-sprout/sprout/registry/env"

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