如何在谷歌appengine上设置环境变量? [英] how to set environment variables on google appengine?
本文介绍了如何在谷歌appengine上设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在谷歌应用引擎上设置和使用环境变量。我的app.yaml文件如下所示。但是,当我使用os.Getenv(mytoken)时,我得到一个空字符串,而不是我设置的实际值。这是一个GAE错误吗?
I'm trying to set and use an environment variable on google app engine. My app.yaml file looks as below. However when I use os.Getenv("mytoken") I get an empty string instead the actual value I set. Is it a GAE bug?
api_version: go1
handlers:
- url: /.*
script: _go_app
env_variables:
mytoken: '88786d9b9a0359824'
推荐答案
此功能现已记录在此处。但是,正如我刚才测试的那样,它不适用于AppEngine。它在本地服务器上工作,所以不要被愚弄。。
The feature is now documented here. However, as I have tested just now, it doesn't work on AppEngine. It does work on local server, so don't be fooled..
编辑:它适用于Google AppEngine。我以前的失败是由于一个错误。考虑一下:
It works on Google AppEngine. My previous failure is due to a mistake. Consider this:
import "os"
var consumer = OAuth1Consumer{
secret: os.Getenv("secret")
}
如果声明为全局变量。
这篇关于如何在谷歌appengine上设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文