Is there a way to detect whether the code is run on local, test environment or on App Engine?

development-environment, environment-variables, go, google-app-engine, testing

Solution

Have you read the docs on the runtime environemnt.

It points to this document https://developers.google.com/appengine/docs/go/reference which lists a bunch of functions that give you information about the runtime environemnt.

Specifically

 func IsDevAppServer() bool

Problem

I am developing a Google App Engine Go application and testing it locally. I have some variables for test environment and some variables for the live App Engine environment. I am wondering whether there is some way to determine from inside the code what environment the code is run in and use a proper version of the variable without having to comment and uncomment code all the time.

Original source