以下 app.yaml 演示了如何将应用配置为使用最新 Go 版本。如需使用任何其他受支持版本的 Go,您必须更新 app.yaml 文件。如需了解详情,请参阅 Go 运行时。
runtime:goenv:flexruntime_config:operating_system:'ubuntu22'# This sample incurs costs to run on the App Engine flexible environment.# The settings below are to reduce costs during testing and are not appropriate# for production use. For more information, see:# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yamlmanual_scaling:instances:1resources:cpu:1memory_gb:0.5disk_size_gb:10
您可能只需在相应的 app.yaml 文件中定义几个元素,具体取决于应用服务的复杂程度。以下示例演示了简单的 Go 应用可能需要在柔性环境中定义的元素:
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file is essential for configuring an App Engine app, defining its CPU, memory, network, disk resources, scaling, and environment variables.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify the Go runtime version and URLs within the \u003ccode\u003eapp.yaml\u003c/code\u003e file, which acts as the deployment descriptor for a specific service version.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file for the default service of your app must be created before creating and deploying \u003ccode\u003eapp.yaml\u003c/code\u003e files for additional services.\u003c/p\u003e\n"],["\u003cp\u003eWhile you can rename \u003ccode\u003eapp.yaml\u003c/code\u003e files, using a custom name necessitates specifying the file name in the deployment command.\u003c/p\u003e\n"],["\u003cp\u003eSome Go runtimes have reached their end of support, therefore, it's advised that you upgrade to the latest version of Go, and note that you will not be able to redeploy versions after their end of support date.\u003c/p\u003e\n"]]],[],null,["# Configuring your app with app.yaml\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n| **Note:** Some [Go runtimes](/appengine/docs/flexible/lifecycle/support-schedule#go) have reached [end of support](/appengine/docs/flexible/lifecycle/runtime-lifecycle#end_of_support). You cannot re-deploy versions that use runtimes after their end of support date. We recommend that you [upgrade your app](/appengine/docs/flexible/go/runtime#newversions) to use the latest version of Go.\n\n\u003cbr /\u003e\n\n\nAn App Engine app is configured using an `app.yaml`\nfile, that contains CPU, memory, network and disk resources, scaling, and other\ngeneral settings including environment variables.\n\n\nAbout `app.yaml` files\n----------------------\n\n\u003cbr /\u003e\n\nYou can specify the runtime configuration for your Go app, including versions and URLs, in the `app.yaml` file. This file acts as a deployment descriptor of a specific [service](/appengine/docs/flexible/an-overview-of-app-engine) version.\n\n\u003cbr /\u003e\n\n\nYou must first create the `app.yaml` file for the `default` service of your app\nbefore you can create and deploy `app.yaml` files for additional services.\n\n\nThe following `app.yaml` demonstrates how to configure your app to use the latest\nGo version. To use any other [supported version](/appengine/docs/flexible/lifecycle/support-schedule#go) of Go,\nyou must update your `app.yaml` file. For more information, see\n[Go runtime](/appengine/docs/flexible/go/runtime). \n\n runtime: go\n env: flex\n\n runtime_config:\n operating_system: 'ubuntu22'\n\n # This sample incurs costs to run on the App Engine flexible environment.\n # The settings below are to reduce costs during testing and are not appropriate\n # for production use. For more information, see:\n # https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml\n manual_scaling:\n instances: 1\n resources:\n cpu: 1\n memory_gb: 0.5\n disk_size_gb: 10\n\n\nDepending on the complexity of your app's service, you might only need to define\na few elements in the corresponding `app.yaml` file. The following example\ndemonstrates what a simple Go app might require in the\nflexible environment:\n\n\nYou can specify a unique name for your `app.yaml` files, but then you must\nspecify the file name with the [deployment\ncommand](/appengine/docs/flexible/testing-and-deploying-your-app)\nas well. For example, if you name your `app.yaml` file `service-name-app.yaml`\nor `app.flexible.yaml`, then you must deploy your app using either: \n\n gcloud app deploy service-name-app.yaml\n gcloud app deploy app.flexible.yaml\n\nTo learn more about structuring multiple services and `app.yaml` files in your app, see [Structuring web services](/appengine/docs/flexible/configuration-files).\n\n\u003cbr /\u003e\n\nAll configuration elements\n--------------------------\n\nFor a complete list of all the supported elements in this configuration file,\nsee the\n[`app.yaml` reference](/appengine/docs/flexible/reference/app-yaml)."]]