[[["易于理解","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-28。"],[[["\u003cp\u003eGo runtime in the flexible environment requires \u003ccode\u003egcloud CLI\u003c/code\u003e version 420.0.0 or later, and you can manage dependencies with a \u003ccode\u003ego.mod\u003c/code\u003e file placed in the same folder as the \u003ccode\u003eapp.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eTo specify a Go version and operating system, include the \u003ccode\u003eruntime_config\u003c/code\u003e and \u003ccode\u003eoperating_system\u003c/code\u003e settings in your \u003ccode\u003eapp.yaml\u003c/code\u003e file, and optionally, the \u003ccode\u003eruntime_version\u003c/code\u003e to define a specific version.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine automatically updates to new patch revisions of the specified Go version, but it will not automatically update to a new major version.\u003c/p\u003e\n"],["\u003cp\u003eGo versions 1.15 and earlier are no longer supported, so it is recommended to migrate to a supported version or use a custom runtime.\u003c/p\u003e\n"],["\u003cp\u003eEnsure all dependencies are included to avoid build failures by collecting them from your local \u003ccode\u003eGOPATH\u003c/code\u003e and testing locally before deploying your application.\u003c/p\u003e\n"]]],[],null,["# The Go runtime\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\nThe Go runtime is the software stack responsible for\ninstalling your application code and dependencies, and then running that\napplication in the flexible environment.\n\nGo versions\n-----------\n\nGo 1.25 uses\n[buildpacks](/docs/buildpacks/overview). For the full list of supported\nGo versions, and their corresponding Ubuntu\nversion, see the [Runtime support schedule](/appengine/docs/flexible/lifecycle/support-schedule#go).\n\nTo use a [supported](/appengine/docs/flexible/lifecycle/support-schedule#go)\nGo version, you must:\n\n- Install `gcloud CLI` version **420.0.0 or later** . You can update\n your CLI tooling by running the [`gcloud components update`](/sdk/gcloud/reference/components/update)\n command. To view your installed version, you can run the [`gcloud version`](/sdk/gcloud/reference/version)\n command.\n\n- Go recommends that you use a `go.mod` file for managing dependencies.\n To install dependencies during deployment, include a `go.mod` file in the same\n folder as the `app.yaml` file.\n\n For example, the folder structure of your app with `go.mod` must represent: \n\n \u003capplication-root\u003e/\n --\u003e app.yaml\n --\u003e go.mod\n --\u003e Other source files used in your application.\n\n- Include the `runtime_config` and `operating_system` settings in your\n [`app.yaml`](/appengine/docs/flexible/reference/app-yaml#general) file\n to specify an operating system.\n\n- Optionally, you can specify a runtime version by including the `runtime_version`\n setting in your `app.yaml`. By default, the latest Go version is used if\n the `runtime_version` setting is not specified.\n\n**Examples**\n\n- To specify Go 1.25 on Ubuntu 22:\n\n runtime: go\n env: flex\n\n runtime_config:\n operating_system: \"ubuntu22\"\n runtime_version: \"1.25\"\n\n- To specify the latest supported Go version on Ubuntu 22:\n\n runtime: go\n env: flex\n\n runtime_config:\n operating_system: \"ubuntu22\"\n\nYour app uses the latest stable release of the version that is specified in your\n`app.yaml` file. App Engine automatically updates to new patch revisions, but\nit won't automatically update the major version.\n\nFor example, your application might be deployed at Go 1.18.10, and later it might be\nautomatically updated to Go 1.18.11, but it won't be automatically updated to\nthe major version Go 1.19.\n\nChoosing Go 1.25 in your `app.yaml` file results in\nthe latest `patch` version of Go 1.25 available. \n\n runtime: go\n env: flex\n\n runtime_config:\n operating_system: \"ubuntu22\"\n runtime_version: \"1.25\"\n\nSee the [`app.yaml`](/appengine/docs/flexible/reference/app-yaml) reference for more information.\n\n### Previous runtime versions\n\n| **Warning:** Go **version 1.15 and earlier** have reached end of support. App Engine blocks you from deploying your applications using runtimes that have reached end of support. We recommend that you migrate your app to use a [supported version](/appengine/docs/flexible/lifecycle/support-schedule#go) of Go or use a [custom runtime](/appengine/docs/flexible/custom-runtimes/about-custom-runtimes).\n\nTo use Go **version 1.15 and earlier** , specify a version in\n`runtime` setting using the `go1.x` format in your\n[`app.yaml`](/appengine/docs/flexible/reference/app-yaml) file. For example:\n\n\u003cbr /\u003e\n\n```go\n runtime: go1.14\n env: flex\n```\n\n\u003cbr /\u003e\n\nIf no version is specified, the default version of `go1.11` will be automatically\nselected.\n\nYour app uses the latest stable release of the version that is specified in your\n`app.yaml` file. App Engine automatically updates to new patch revisions, but\nit won't automatically update the major version.\n\nFor example, your application might be deployed at Go 1.14.10, and later it might be\nautomatically updated to Go 1.14.11, but it won't be automatically updated to\nthe major version Go 1.15.\n\nChoosing the go runtime version `go1.15` in your `app.yaml` file results in\nthe latest version of 1.15 available, for example, 1.15.15. \n\n```go\n runtime: go1.15\n env: flex\n```\n\n### Support for other Go runtimes\n\nIf you need to use a Go version that isn't [supported](/appengine/docs/flexible/lifecycle/support-schedule#go), you can create a\n[custom runtime](/appengine/docs/flexible/custom-runtimes/build) and select a\nvalid base image with the Go version you need.\n\nFor Google-supplied base images or\n[Docker Go base images](https://hub.docker.com/_/golang),\nsee [Building custom runtimes](/appengine/docs/flexible/custom-runtimes/build#base).\n\nImport packages\n---------------\n\nYour code compiles when you deploy your app to App Engine. When you\nrun the deployment command, your app's dependencies are first collected from\nyour local `GOPATH` and then they are all sent to the build server. Any missing\ndependencies, for example third-party libraries, results in build failures.\n\nTo avoid build failures and ensure that all your app's dependencies get deployed\nwith your code, you should [test your app locally before deploying\nit](/appengine/docs/flexible/testing-and-deploying-your-app).\n\nExtending the runtime\n---------------------\n\nFor instructions on how to extend and customize the Go runtime, read the\n[Go runtime builder on GitHub](https://github.com/GoogleCloudPlatform/golang-docker/tree/master/runtime-builder).\n\nMetadata server\n---------------\n\nEach instance of your application can use the\n[Compute Engine metadata server](/compute/docs/storing-retrieving-metadata) to query information\nabout the instance, including its host name, external IP address, instance ID,\ncustom metadata, and service account information. App Engine does not allow you\nto set custom metadata for each instance, but you can set\n[project-wide custom metadata](/compute/docs/storing-retrieving-metadata#projectwide) and read it\nfrom your App Engine and Compute Engine instances.\n\nUse the\n[`cloud.google.com/go/compute/metadata`](https://godoc.org/cloud.google.com/go/compute/metadata)\npackage to access the metadata server."]]