douchun6108 2018-07-23 21:48
浏览 75
已采纳

使用App Engine golang灵活环境,在测试时访问app.yaml

I am porting a golang service from App Engine standard environment to the flexible environment, and have a question about accessing app.yaml during development/testing.

In my app.yaml I have a section where I set environment variables, that I later access in the code via os.GetEnv(...):

env_variables:
  FORGE_CLIENT_ID: 'my-client-id'
  FORGE_CLIENT_SECRET: 'my-client-secret'

In the App Engine standard environment, this runs fine, as I am using the app engine development server dev-server.py, which I believe takes care of reading the app.yaml file and making these environment variables available.

However, in the flexible environment during development, the service is started simply with go run *.go, and the app doesn't seem to pick up any information in app.yaml, meaning I get an error that my environment variables are not set.

I understand that app.yaml is used during deployment in the flexible environment, but I don't understand how or if it is used during development. How do I access these environment variables from my development server?

Thanks.

  • 写回答

2条回答 默认 最新

  • douhu2898 2018-07-24 14:37
    关注

    For Google App Engine flexible, the dev server don't use "app.yaml", as the configuration is set locally. A workaround for this would be to set the environment variables before running the dev server. You can check this question for setting those variables just for that command.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测