Loads environment variables from .env into ENV, automagically.
go get github.com/jpfuentes2/go-env
Autoloading your $PWD/.env
is as simple as importing the go-env/autoload
package:
import _ "github.com/jpfuentes2/go-env/autoload"
That's fine. Chillllll, Winston:
package main
import "github.com/jpfuentes2/go-env"
func main() {
env.ReadEnv("/path/to/my/file")
}
See the examples folder.
Export GOENV
from your shell to specify a different env file to be loaded.
For example:
export GOENV=test
Would result in .env.test
being loaded instead of .env
.
Please note that development is considered to map to .env
. So exporting GOENV=development
will mean that .env
is loaded.
Created and maintained by
- Jacques Fuentes - @jpfuentes2
I've been sourcing .env
files for quite some time in Ruby projects, but I did copy some of the vebiage/style from dotenv.
Also, I used copied some code from goreman.
Thanks to Yasuhiro Matsumoto and Brandon Keepers.
MIT