Documentation
¶
Index ¶
- func Exec(filenames []string, cmd string, cmdArgs []string, overload bool) error
- func Load(filenames ...string) (err error)
- func Marshal(envMap map[string]string) (string, error)
- func Overload(filenames ...string) (err error)
- func Parse(r io.Reader) (map[string]string, error)
- func Read(filenames ...string) (envMap map[string]string, err error)
- func Unmarshal(str string) (envMap map[string]string, err error)
- func UnmarshalBytes(src []byte) (map[string]string, error)
- func Write(envMap map[string]string, filename string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exec ¶
Exec loads the env vars from the specified filenames, then executes the specified command. Simply connect os.stdin/err/out to the command and call Run(). If you need finer command control, recommend using `Load()`, `Overload()` or `Read()` and the `os/exec` package.
func Load ¶
Load reads the env file(s) and loads them into ENV for this process. Call this function as close as possible to the beginning of your program (ideally in main). If you call Load without any args, it will load the .env at the current path by default. Otherwise you can tell it which files to load (there can be more than one), for example:
env.Load("fileone", "filetwo")
It is important to note that it DOES NOT DELETE env variables that already exist - use the .env file to set dev vars or reasonable defaults.
func Marshal ¶
Marshal outputs the given environment as a dotenv format environment file. Each line has the format: KEY="VALUE", where VALUE is backslash-escaped.
func Overload ¶
Overload reads your env file(s) and loads them into ENV for this process. Call this function as close as possible to the beginning of program (ideally in main). If you call Overload without any args, it will load the .env at the current path by default. Otherwise you can tell it which files to load (there can be several), for example:
godotenv.Overload("fileone", "filetwo")
It is important to note that this OVERRIDE an env variable that already exists - think of the .env file as forcibly setting all variables.
func Read ¶
Read reads all envs (with the same load semantics as Load), but returns the values as a map instead of automatically writing them to the env.
func UnmarshalBytes ¶
UnmarshalBytes parses env file from byte slices of characters, returning a map of keys and values.
Types ¶
This section is empty.