Environment variables

1,073 views
Skip to first unread message

Ryan Wolf

unread,
Apr 3, 2012, 3:24:12 PM4/3/12
to google-appengine-go
I am writing a simple web app for serving novelty domains like
isitchristmas.com in appengine.

I'd like to host the source code on github, and I'd like to use basic
auth for letting the site owner change the answer from yes to no.

Since hardcoding the password in my open source app won't work, for
setting the username/password on other PaaS, I would set an
environment variable:
https://devcenter.heroku.com/articles/config-vars
http://new-wiki.joyent.com/display/node/Node.js+SmartMachine+FAQ#Node.jsSmartMachineFAQ-IneedtopasssomeAPIcredentialstomyNode.jsprocess

How do I set/get environment variables in go on appengine?

David Symonds

unread,
Apr 4, 2012, 12:14:19 AM4/4/12
to Ryan Wolf, google-appengine-go
On Wed, Apr 4, 2012 at 5:24 AM, Ryan Wolf <rwolf....@gmail.com> wrote:

> How do I set/get environment variables in go on appengine?

Environment variables aren't a good idea on App Engine. They aren't
shared across your app instances, and multiple requests can be running
on a single instance at once. It sounds like you want to store the
password in datastore, and cache it in a global var in the app
instance.


Dave.

David Symonds

unread,
Apr 4, 2012, 2:39:05 AM4/4/12
to Ryan Wolf, google-appengine-go
On Wed, Apr 4, 2012 at 3:01 PM, Ryan Wolf <rwolf....@gmail.com> wrote:

> I understand that a flat file I read from or sticking this in the db will
> work. I'm asking if Google App Engine has environment variables a la heroku
> or joyent.

In Go, no. If it doesn't need to dynamically change, sticking it in a
config.go file works well. It's what we do for build.golang.org, which
is an App Engine application.


Dave.

Ryan Wolf

unread,
Apr 4, 2012, 1:01:30 AM4/4/12
to David Symonds, google-appengine-go
In the two examples I provided, similar services provided a simple way to set read only, shared with all instances variables. Maybe asking about user auth is the wrong way to bring this up (especially since gae has that whole google login thing I could use), consider an app that talks to twitter a needs an API key instead.

I understand that a flat file I read from or sticking this in the db will work. I'm asking if Google App Engine has environment variables a la heroku or joyent.

Rodrigo Moraes

unread,
Apr 4, 2012, 7:16:19 AM4/4/12
to google-appengine-go
On Apr 4, 2:01 am, Ryan Wolf wrote:
> I'm asking if Google App Engine has environment variables a la heroku
> or joyent.

It doesn't.

-- rodrigo

Andrew Gerrand

unread,
Apr 4, 2012, 5:27:24 PM4/4/12
to David Symonds, Ryan Wolf, google-appengine-go
Actually if you look at the source for build.golang.org you'll see hat we store the builder key in the datastore and retrieve it once on startup. 

http://golang.org/misc/dashboard/app/build/key.go

Andrew

miha...@gmail.com

unread,
Mar 21, 2015, 3:59:27 PM3/21/15
to google-ap...@googlegroups.com, dsym...@golang.org, rwolf....@gmail.com
Is this a limitation of the GAE Go runtime? On python the env variables can be set in the  yaml file[0] which I find pretty neat. 

Glenn Lewis

unread,
Mar 21, 2015, 4:00:54 PM3/21/15
to miha...@gmail.com, google-appengine-go, David Symonds, rwolf....@gmail.com
Yes, classic Go on App Engine apps do not support the passing of environment variables to the app.
-- Glenn

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dclo...@gmail.com

unread,
Apr 9, 2015, 12:54:37 PM4/9/15
to google-ap...@googlegroups.com, miha...@gmail.com, dsym...@golang.org, rwolf....@gmail.com
Looks like the file that Andrew was referring to moved here.

Actually if you look at the source for build.golang.org you'll see hat we store the builder key in the datastore and retrieve it once on startup. 
http://golang.org/misc/dashboard/app/build/key.go
Andrew

"gophers rule" is not the real key :-)

In the same project, here, are you creating a new key every time an new instance is created (or on each request)? 
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages