【问题标题】:Is there a way to detect whether the code is run on local, test environment or on App Engine?有没有办法检测代码是在本地、测试环境还是在 App Engine 上运行?
【发布时间】:2014-07-10 17:45:33
【问题描述】:

我正在开发一个 Google App Engine Go 应用程序并在本地对其进行测试。我有一些用于测试环境的变量和一些用于实时 App Engine 环境的变量。我想知道是否有某种方法可以从代码内部确定代码在什么环境中运行并使用正确版本的变量,而不必一直注释和取消注释代码。

【问题讨论】:

  • 恭喜,我想你得到了第 5000 个 [Go] 问题。

标签: google-app-engine testing go environment-variables development-environment


【解决方案1】:

您是否阅读过有关运行时环境的文档。

它指向这个文档https://developers.google.com/appengine/docs/go/reference,其中列出了一系列函数,这些函数可以为您提供有关运行时环境的信息。

具体

 func IsDevAppServer() bool

【讨论】:

    猜你喜欢
    • 2018-08-18
    • 1970-01-01
    • 2017-03-12
    • 2019-09-23
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多