Skip to content

Commit

Permalink
NO-ISSUE - add support for env file loading
Browse files Browse the repository at this point in the history
Signed-off-by: Al Hoang <[email protected]>
  • Loading branch information
hoanga committed Jul 28, 2020
1 parent 9334568 commit 09cf163
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package mainflux

import (
"os"

"github.com/subosito/gotenv"
)

// Env reads specified environment variable. If no value has been found,
Expand All @@ -16,3 +18,9 @@ func Env(key, fallback string) string {

return fallback
}

// LoadEnvFile loads environment variables defined in an .env formatted file.
func LoadEnvFile(envfilepath string) error {
err := gotenv.Load(envfilepath)
return err
}
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ github.com/spf13/viper
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
# github.com/subosito/gotenv v1.2.0
## explicit
github.com/subosito/gotenv
# github.com/uber/jaeger-client-go v2.24.0+incompatible
## explicit
Expand Down

0 comments on commit 09cf163

Please sign in to comment.