> For the complete documentation index, see [llms.txt](https://docs.atom.codes/sprout/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.atom.codes/sprout/registries/env.md).

# Env

{% hint style="info" %}
You can easily import all the functions from the <mark style="color:yellow;">`env`</mark> registry by including the following import statement in your code

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

{% endhint %}

### <mark style="color:purple;">env</mark>

The function retrieves the value of a specified environment variable from the system.

<table data-header-hidden><thead><tr><th width="174">Name</th><th>Value</th></tr></thead><tbody><tr><td>Signature</td><td><pre class="language-go"><code class="lang-go">Env(key string) string
</code></pre></td></tr></tbody></table>

{% tabs %}
{% tab title="Template Example" %}

```go
{{ env "INVALID" }} // Output: ""
{{ "PATH" | env }} // Output(will be different): "/usr/bin:/bin:/usr/sbin:/sbin"
```

{% endtab %}
{% endtabs %}

### <mark style="color:purple;">expandEnv</mark>

The function replaces occurrences of `${var}` or `$var` in a string with the corresponding values from the current environment variables.

<table data-header-hidden><thead><tr><th width="164">Name</th><th>Value</th></tr></thead><tbody><tr><td>Signature</td><td><pre class="language-go"><code class="lang-go">ExpandEnv(str string) string
</code></pre></td></tr></tbody></table>

{% tabs %}
{% tab title="Template Example" %}

```go
{{ "Path is $PATH" | expandEnv }} // Output(will be different): "Path is /usr/bin:/bin:/usr/sbin:/sbin"
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atom.codes/sprout/registries/env.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
