Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie die gebündelten Dienste mit der Go-Laufzeit für die App Engine-Standardumgebung installieren und verwenden. Ihre Anwendung kann über das App Engine Services SDK für Go auf die gebündelten Dienste zugreifen.
Um die APIs mit gebündelten Legacy-Diensten mit Go aufzurufen, müssen Sie das neueste SDK verwenden. Gehen Sie so vor:
Aktualisieren Sie die Datei app.yaml mit der folgenden Zeile:
app_engine_apis:true
Fügen Sie einen Verweis auf das neueste SDK in Ihrem go.mod hinzu. Führen Sie dazu go get im Terminal so aus:
gogetgoogle.golang.org/appengine/v2
Der Hauptunterschied beim Upgrade auf Go ist die Verwendung von Version 2 des App Engine-Dienste-SDK.
Ändern Sie in der Anwendung die Importanweisungen durch Einfügen von /v2/ in die alten Paketnamen. Wenn Sie beispielsweise Memcache verwenden, gehen Sie so vor:
Führen Sie go mod tidy aus, um Referenzen in der Datei go.mod zu bereinigen.
gomodtidy
Hinweise zur Migration
Beachten Sie die folgenden Überlegungen, wenn Sie zur Go-Laufzeit migrieren und Ihre Anwendung gebündelte Legacy-Dienste verwendet:
Wenn Sie die Funktionen eines gebündelten Legacy-Dienstes in Ihrer Go-Anwendung testen möchten, führen Sie Ihre Anwendung in Ihrer lokalen Umgebung aus. Verwenden Sie dabei die Entwicklungstools, die Sie sonst auch verwenden, z. B. go run.
Verwenden Sie zum Bereitstellen der Anwendung den Befehl gcloud app deploy.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-04-21 (UTC)."],[[["\u003cp\u003eThis guide outlines the process of installing and utilizing the App Engine services SDK for Go, enabling access to legacy bundled services within the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you must update your \u003ccode\u003eapp.yaml\u003c/code\u003e file to include \u003ccode\u003eapp_engine_apis: true\u003c/code\u003e and ensure you are using the latest SDK by referencing \u003ccode\u003egoogle.golang.org/appengine/v2\u003c/code\u003e in your \u003ccode\u003ego.mod\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eWhen updating from older SDK versions, the key change is the inclusion of \u003ccode\u003e/v2/\u003c/code\u003e in import statements within your Go application code, such as \u003ccode\u003egoogle.golang.org/appengine/v2/memcache\u003c/code\u003e for Memcache.\u003c/p\u003e\n"],["\u003cp\u003eBefore beginning migration to Go, be sure to review the runtime migration overview and make yourself aware of the migration considerations.\u003c/p\u003e\n"],["\u003cp\u003eTesting of legacy bundled services in a Go application can be performed locally using tools like \u003ccode\u003ego run\u003c/code\u003e, and deployment is achieved using the \u003ccode\u003egcloud app deploy\u003c/code\u003e command.\u003c/p\u003e\n"]]],[],null,["# Access legacy bundled services for Go\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nThis page describes how to install and use the bundled\nservices with the [Go runtime](/appengine/docs/standard/go/runtime)\nfor App Engine standard environment. Your app can access the bundled services\nthrough the **App Engine services SDK for Go**.\n\nBefore you begin\n----------------\n\n- Refer to the [list of legacy bundled services APIs](/appengine/docs/standard/services/overview) you can call in the Go runtime.\n- Before starting a migration project to Go, see the [runtime migration overview](/appengine/migration-center/standard/migrate-to-second-gen/go-differences) and [migration considerations](#migration) when using legacy bundled services.\n\nInstalling the App Engine services SDK\n--------------------------------------\n\nIn order to call the legacy bundled services APIs with Go, you\nmust use the latest SDK. Follow these steps:\n\n1. Update your [`app.yaml`](/appengine/docs/standard/reference/app-yaml#app_engine_apis)\n file to include the following line:\n\n app_engine_apis: true\n\n2. Add a reference to the latest SDK in your `go.mod` file by running `go get`\n in the terminal as follows:\n\n go get google.golang.org/appengine/v2\n\n The main difference when upgrading to Go is using v2 of the App Engine services SDK.\n3. In your app, modify your import statements by inserting `/v2/` in the old\n package names. For example, if using Memcache, do the following:\n\n import (\n \"google.golang.org/appengine/v2\"\n \"google.golang.org/appengine/v2/memcache\"\n )\n\n For the full list of available package names, see the\n [legacy bundled services API references documentation](/appengine/docs/standard/go/reference/services/bundled/latest).\n4. Run `go mod tidy` to clean up references in your `go.mod` file.\n\n go mod tidy\n\n| **Note:** When upgrading to a new major version of a Go dependency, such as a package or library, make sure to include the major version number of the dependency in your import statements. If you run `go mod tidy` and find that it is still importing an older version of the App Engine services SDK for Go, you have probably missed upgrading an import statement.\n\nMigration considerations\n------------------------\n\nYou should be aware of the following considerations if you are migrating to\nthe Go runtime and your app uses legacy bundled services:\n\n- To test the legacy bundled services functionality in your Go app, [run your application in your local environment](/appengine/docs/standard/testing-and-deploying-your-app#running_locally) with the development tools that you usually use, such as `go run`.\n- To deploy your app, use the [`gcloud app deploy`](/appengine/docs/standard/go/building-app#deploying_your_web_service_on) command."]]