env

package
v15.11.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractValue

func ExtractValue(environment []string, key string) string

ExtractValue returns the value of the environment variable with the given key. The given key should not have a trailing "=". If the same key occurrs multiple times in the environment, then any later occurrences will override previous ones.

func GetBool

func GetBool(name string, fallback bool) (bool, error)

GetBool fetches and parses a boolean typed environment variable

If the variable is empty, returns `fallback` and no error. If there is an error, returns `fallback` and the error.

func GetDuration

func GetDuration(name string, fallback time.Duration) (time.Duration, error)

GetDuration fetches and parses a duration typed environment variable

func GetInt

func GetInt(name string, fallback int) (int, error)

GetInt fetches and parses an integer typed environment variable

If the variable is empty, returns `fallback` and no error. If there is an error, returns `fallback` and the error.

func GetString

func GetString(name string, fallback string) string

GetString fetches a given name from the environment and falls back to a default value if the name is not available. The value is stripped of leading and trailing whitespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL