Reputation: 144
According to the docs, you just have to include them in the app.yaml file https://cloud.google.com/appengine/docs/go/config/appconfig#Go_app_yaml_Defining_environment_variables
So I did that like this:
env_variables:
DEVDOT_OAUTH_CLIENT_ID: 'xxxxx'
DEVDOT_OAUTH_CLIENT_SECRET: 'xxxxxx'
But when my application runs, it doesn't get these values. I'm running on a MVM runtime so I removed my init() function and tried calling os.Getenv() from both main() and from a handler I had assigned to the /_ah/start path.
Any ideas?
Upvotes: 1
Views: 864
Reputation: 11
I think you have to get the env variables from the app.yaml file?. This works for me:
Upvotes: 1
Reputation: 881555
As how to set environment variables on google appengine? explains, "environment variables are not ready until all the init functions are run and I would say same might be applying to the global variable declaration too. It works from a function because by that time environment variables are set".
You appear to be saying otherwise -- can you try the example code at the other Q I pointed to, which was working when that Q was answered, and tell us what you observe instead?
Upvotes: 1