Documentation ¶
Overview ¶
Package env provides functionality for ensuring we retrieve an environment variable
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustGet ¶
MustGet returns an environment variable by name If the requested variable does not exist, we throw a fatal error
Example ¶
package main import ( "log" "github.com/LUSHDigital/core/env" ) func main() { var dbURL = env.MustGet("DATABASE_URL") log.Println(dbURL) }
Output:
func TryLoadDefault ¶ added in v0.5.3
func TryLoadDefault(paths ...string)
TryLoadDefault will attempt to load the default environment variables. This WILL NOT OVERRIDE an env variable that already exists. Those set prior to this call will remain. For env variables set in multiple files passed to this function, the FIRST one will prevail.
Example ¶
package main import ( "github.com/LUSHDigital/core/env" ) func main() { env.TryLoadDefault() }
Output:
func TryOverloadDefault ¶ added in v0.19.0
func TryOverloadDefault(paths ...string)
TryOverloadDefault will attempt to load the default environment variables. This WILL OVERRIDE an env variable that already exists. Those set prior to this call will be replaced if set here. For env variables set in multiple files passed to this function, the LAST one will prevail.
Example ¶
package main import ( "github.com/LUSHDigital/core/env" ) func main() { env.TryOverloadDefault() }
Output:
Types ¶
This section is empty.