env

package
v2.7.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(names ...string) (map[string]string, error)

Get environment variables

func GetOrDefaultBool

func GetOrDefaultBool(envVar string, defaultValue bool) bool

GetOrDefaultBool returns the given environment variable value as a boolean. Returns the default if the envvar cannot be coopered to a boolean, or is not found.

func GetOrDefaultInt

func GetOrDefaultInt(envVar string, defaultValue int) int

GetOrDefaultInt returns the given environment variable value as an integer. Returns the default if the envvar cannot be coopered to an int, or is not found.

func GetOrDefaultSecond

func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration

GetOrDefaultSecond returns the given environment variable value as an time.Duration (second). Returns the default if the envvar cannot be coopered to an int, or is not found.

func GetOrDefaultString

func GetOrDefaultString(envVar string, defaultValue string) string

GetOrDefaultString returns the given environment variable value as a string. Returns the default if the envvar cannot be find.

func GetOrFile

func GetOrFile(envVar string) string

GetOrFile Attempts to resolve 'key' as an environment variable. Failing that, it will check to see if '<key>_FILE' exists. If so, it will attempt to read from the referenced file to populate a value.

func GetWithFallback

func GetWithFallback(groups ...[]string) (map[string]string, error)

GetWithFallback Get environment variable values The first name in each group is use as key in the result map

// LEGO_ONE="ONE"
// LEGO_TWO="TWO"
env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"})
// => "LEGO_ONE" = "ONE"

----

// LEGO_ONE=""
// LEGO_TWO="TWO"
env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"})
// => "LEGO_ONE" = "TWO"

----

// LEGO_ONE=""
// LEGO_TWO=""
env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"})
// => error

Types

This section is empty.

Jump to

Keyboard shortcuts

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