Documentation ¶
Overview ¶
Package gotenv provides functionality to dynamically load the environment variables
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load is function to load a file or multiple files and then export the valid variables which found into environment variables. When it's called with no argument, it will load `.env` file on the current path and set the environment variables. Otherwise, it will loop over the filenames parameter and set the proper environment variables.
// processing `.env` gotenv.Load() // processing multiple files gotenv.Load("production.env", "credentials")
Types ¶
type Env ¶
Holds key/value pair of valid environment variable
func Parse ¶
Parse if a function to parse line by line any io.Reader supplied and returns the valid Env key/value pair of valid variables. It expands the value of a variable from environment variable, but does not set the value to the environment itself. This function is skipping any invalid lines and only processing the valid one.
Example ¶
package main import ( "fmt" "github.com/ddollar/forego/Godeps/_workspace/src/github.com/subosito/gotenv" "strings" ) func main() { pairs := gotenv.Parse(strings.NewReader("FOO=test\nBAR=$FOO")) fmt.Printf("%+v\n", pairs) // gotenv.Env{"FOO": "test", "BAR": "test"} pairs = gotenv.Parse(strings.NewReader(`FOO="bar"`)) fmt.Printf("%+v\n", pairs) // gotenv.Env{"FOO": "bar"} }
Output: