ANN godotenv - port of Ruby's dotenv library

150 views
Skip to first unread message

John Barton

unread,
Jul 31, 2013, 1:04:19 AM7/31/13
to golan...@googlegroups.com
Hi everyone,

Just wanted to share a link to a library I just published today: https://github.com/joho/godotenv

I've been building some go apps to deploy to heroku, and I realised I really missed the workflow I had with Ruby which is to store all my development ENV variables in a .env file locally using the https://github.com/bkeepers/dotenv library.

So I ported it across as a bit of a yak-shave :-)

Anyway, I hope someone here finds it useful. I'm still pretty new to Go, so if anyone feels like giving it a quick code review and sending comments over (or pull requests) that'd be much appreciated.

Cheers,
John

Ryan Smith

unread,
Aug 11, 2013, 5:05:30 PM8/11/13
to golan...@googlegroups.com
Can you help me understand what problem this lib is solving? I can certainly look at your implementation, but first I would like to better understand the problem. For instance, are you improving on the standard way of reading environment variable?

$ echo 'TZ=UTC' >> .env
$ export $(cat .env)
$ cat x.go
package main
import "os"
func main() {
print(os.Getenv("TZ") + "\n")
}
$ go run x.go
UTC

John Barton

unread,
Aug 12, 2013, 7:57:15 PM8/12/13
to golan...@googlegroups.com
It's mostly to make it a bit easier to manage env variables across multiple environments (dev/test/production) especially where you might not have control of the environment ie. Paas hosting services like Heroku or managed CI systems.

Pushing the env loading into the app code itself makes it a lot harder to forget to export your vars before a development session, and makes it harder to accidentally bleed settings between projects if you're jumping between them.
Reply all
Reply to author
Forward
0 new messages