I currently have an App Engine Go app with 2 projects: myapp-prod
and myapp-staging
.
I'd like to be able to set the value of certain variables depending if the app is running in prod or staging.
Is there a way for the app to detect which environment it is running in?
Thanks
You can use the
appengine.AppID()
function to get the name/id of your application:And you can use
appengine.IsDevAppServer()
to tell if your app is running in development mode (using the AppEngine SDK) or live (in production):Alternatively you can also use
appengine.ServerSoftware()
which contains both of the information above, merged into one string:Use an environment variable describing whether your app is on production or staging. Add to
app.yml
,In your code,