🌱
Sprout
Github
  • About
  • Roadmap to Sprout v1.0
  • Migration from Sprig
  • Introduction
    • Getting Started
    • Templating Conventions
  • Features
    • Loader System (Registry)
    • Loader System (Registry Group)
    • Function Aliases
    • Function Notices
    • Safe Functions
  • Registries
    • List of all registries
    • Backward
    • Checksum
    • Conversion
    • Crypto
    • Encoding
    • Env
    • Filesystem
    • Maps
    • Numeric
    • Network
    • Random
    • Reflect
    • Regexp
    • SemVer
    • Slices
    • Std
    • Strings
    • Time
    • Uniqueid
  • Groups
    • List of all registry groups
    • All
    • Hermetic
  • Advanced
    • How to create a handler
    • How to create a registry
    • How to create a registry group
  • Links
    • GitHub repository
Powered by GitBook
On this page
  • env
  • expandEnv
Edit on GitHub
  1. Registries

Env

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

PreviousEncodingNextFilesystem

Last updated 5 months ago

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 "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

{{ "Path is $PATH" | expandEnv }} // Output(will be different): "Path is /usr/bin:/bin:/usr/sbin:/sbin"
Env(key string) string
ExpandEnv(str string) string