From 1736a884e7dd3984ce70558d0df8b72c9c04aa83 Mon Sep 17 00:00:00 2001 From: "John Barton (joho)" Date: Sun, 12 Oct 2014 09:58:10 +1100 Subject: [PATCH] Improve godoc on Read and Exec --- godotenv.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/godotenv.go b/godotenv.go index 83c7a80..816e759 100644 --- a/godotenv.go +++ b/godotenv.go @@ -46,6 +46,10 @@ func Load(filenames ...string) (err error) { return } +/* + Read all env (with same file loading semantics as Load) but return values as + a map rather than automatically writing values into env +*/ func Read(filenames ...string) (envMap map[string]string, err error) { filenames = filenamesOrDefault(filenames) envMap = make(map[string]string) @@ -66,6 +70,15 @@ func Read(filenames ...string) (envMap map[string]string, err error) { return } +/* + Loads env vars from the specified filenames (empty map falls back to default) + then executes the cmd specified. + + Simply hooks up os.Stdin/err/out to the command and calls Run() + + If you want more fine grained control over your command it's recommended + that you use `Load()` or `Read()` and the `os/exec` package yourself. +*/ func Exec(filenames []string, cmd string, cmdArgs []string) error { Load(filenames...)