Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Go 1.11-Anwendung in der App Engine-Standardumgebung erstellen
Regions-ID
REGION_ID ist ein abgekürzter Code, den Google anhand der Region zuweist, die Sie beim Erstellen Ihrer Anwendung ausgewählt haben. Der Code bezieht sich nicht auf ein Land oder eine Provinz, auch wenn einige Regions-IDs häufig verwendeten Länder- und Provinzcodes ähneln können. Bei Anwendungen, die nach Februar 2020 erstellt wurden, ist REGION_ID.r in den App Engine-URLs enthalten. Bei Anwendungen, die vor diesem Datum erstellt wurden, ist die Regions-ID in der URL optional.
Auf dieser Seite erfahren Sie, wie Sie eine einfache App Engine-Anwendung bereitstellen, die eine kurze Nachricht anzeigt. Unter Anwendung erstellen wird Go in App Engine ausführlicher vorgestellt.
Für diesen Leitfaden fallen keine Kosten an. Wenn Sie nur diese Beispielanwendung ausführen, wird Ihr kostenloses Kontingent nicht überschritten.
Hinweis
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Führen Sie den folgenden Befehl aus, um die gcloud-Komponente zu installieren, die die App Engine-Erweiterung für Go 1.11 enthält:
gcloudcomponentsinstallapp-engine-go
App Engine-Standorte
App Engine ist regional, was bedeutet, dass sich die Infrastruktur, in der Ihre Anwendungen ausgeführt werden, in einer bestimmten Region befindet und Google sie so verwaltet, dass sie redundant in allen Zonen innerhalb dieser Region verfügbar ist.
Die Erfüllung der Latenz-, Verfügbarkeits- oder Langlebigkeitsanforderungen ist der wichtigste Gesichtspunkt bei der Auswahl der Region, in der Ihre Anwendungen ausgeführt werden sollen. Sie können im Allgemeinen die Region auswählen, die den Nutzern Ihrer Anwendung am nächsten ist. Sie sollten jedoch die Standorte berücksichtigen, an denen App Engine verfügbar ist, sowie die Standorte der anderen Google Cloud-Produkte und -Dienste, die Ihre Anwendung nutzt. Eine Nutzung von Diensten über mehrere Standorte kann die Latenz der Anwendung sowie die Preise beeinflussen.
Sie können die Region einer Anwendung nicht mehr ändern, nachdem Sie sie festgelegt haben.
Wenn Sie bereits eine App Engine-Anwendung erstellt haben, können Sie die Region mit einer der folgenden Methoden aufrufen:
In dieser Kurzanleitung wird davon ausgegangen, dass Sie mit der Go-Programmiersprache vertraut sind und Go installiert haben.
Hello World-App herunterladen
Wir haben eine einfache Hello World-App für Go erstellt, damit Sie sich schnell mit der Bereitstellung von Apps in der Google Cloud Platform vertraut machen können. Über die folgenden Schritte laden Sie Hello World auf Ihren lokalen Computer herunter.
Laden Sie die Beispiel-App herunter und gehen Sie zum App-Verzeichnis:
Sie können auch das Beispiel als ZIP-Datei herunterladen und entpacken.
Wechseln Sie zu dem Verzeichnis, das den Beispielcode enthält:
cd golang-samples/appengine/go11x/helloworld/
„Hello World” in App Engine bereitstellen
Stellen Sie die Hello World-Anwendung in App Engine bereit. Führen Sie dazu den folgenden Befehl im Verzeichnis golang-samples/appengine/go11x/helloworld aus:
gcloud app deploy
Sehen Sie sich die Live-Anwendung unter https://PROJECT_ID.REGION_ID.r.appspot.com an:
gcloud app browse
Die Nachricht Hello, world! wird nun von einem Webserver bereitgestellt, der auf einer App Engine-Instanz ausgeführt wird.
Sehr gut. Sie haben erfolgreich einen Go-Webdienst in App Engine bereitgestellt.
Bereinigen
Wenn Sie mehr über App Engine erfahren möchten, können Sie Ihr Google Cloud-Projekt beibehalten und mit Anwendung erstellen weitermachen.
Alternativ können Sie Ihr Google Cloud-Projekt löschen, um die Abrechnung für alle in diesem Projekt verwendeten Ressourcen zu beenden.
In the Google Cloud console, go to the Manage resources page.
[[["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-08-18 (UTC)."],[[["\u003cp\u003eThis guide walks you through deploying a basic "Hello World" Go 1.11 application to the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine apps are regional, meaning the infrastructure is located in a specific region you must select during the initial setup, and this region cannot be changed later.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you'll need to initialize your App Engine app using the gcloud CLI, specifying your project and selecting a region.\u003c/p\u003e\n"],["\u003cp\u003eThe sample "Hello World" app can be downloaded from a GitHub repository, and then deployed to App Engine with the \u003ccode\u003egcloud app deploy\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eAfter deploying, the live app can be viewed at a URL containing your project ID and the selected region, and you have the option to delete your project to stop all billing if you are finished.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Create a Go 1.11 app in the App Engine standard environment\n\nCreate a Go 1.11 app in the App Engine standard environment\n===========================================================\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/go111/how-requests-are-routed#region-id). \nOK\n\nThis page shows you how to deploy a basic App Engine application that displays\na short message. For a more in-depth introduction to Go on App Engine,\nsee [Building an App](/appengine/docs/legacy/standard/go111/building-app).\n\nIs App Engine the right computing option for you? See other\n[options for hosting your application on Google Cloud](/docs/choosing-a-compute-option).\n\nCosts\n-----\n\nThere are no costs associated with running this guide. Running this sample app\nalone does not exceed your [free quota](/appengine/docs/legacy/standard/go111/quotas).\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n\u003cbr /\u003e\n\nAdditional prerequisites\n------------------------\n\n1. Initialize your App Engine app with your project and choose its region:\n\n gcloud app create --project=[YOUR_PROJECT_ID]\n\n When prompted, select the [region](/appengine/docs/legacy/standard/go111/locations)\n where you want to locate your App Engine application.\n | **Caution**: You cannot change an app's region once it has been set.\n2. Install the following prerequisites:\n\n - [Download\n and install Git](https://git-scm.com/).\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n3. \n - Run the following command to install the\n [gcloud component](/sdk/docs/managing-components) that includes the\n App Engine extension for Go 1.11:\n\n gcloud components install app-engine-go\n\n### App Engine locations\n\n\u003cbr /\u003e\n\nApp Engine is *regional* , which means the infrastructure that runs your apps is\nlocated in a specific region, and Google manages it so that it is available\nredundantly across\n[all of the zones within that region](/docs/geography-and-regions).\n\nMeeting your latency, availability, or durability requirements are primary\nfactors for selecting the region where your apps are run. You can generally\nselect the region nearest to your app's users, but you should consider [the\nlocations where App Engine is available](/about/locations#region)\nas well as the [locations](/about/locations#region) of the other\nGoogle Cloud products and services that your app uses. Using services\nacross multiple locations can affect your app's latency as well as its\n[pricing](/appengine/pricing).\n\nYou cannot change an app's region after you set it.\n| **Note:** Two locations, which are called `europe-west` and `us-central` in App Engine commands and in the Google Cloud console, are called `europe-west1` and `us-central1`, respectively, elsewhere in Google documentation.\n\nIf you already created an App Engine application, you can view its\nregion by doing one of the following:\n\n- Run the `gcloud app describe` command.\n\n- Open the\n [App Engine Dashboard in the Google Cloud console](https://console.cloud.google.com/appengine).\n The region appears near the top of the page.\n\nOK\n\nThis quickstart assumes that you are familiar with the Go programming language\nand that you have [installed Go](https://golang.org/doc/install).\n\nDownload the Hello World app\n----------------------------\n\nWe've created a simple Hello World app for Go so you can quickly get a feel for\ndeploying an app to Google Cloud Platform. Follow these steps to download Hello\nWorld to your local machine.\n\nDownload the sample app and navigate into the app directory:\n\n1. Clone the [Hello World sample app repository](https://github.com/GoogleCloudPlatform/golang-samples.git):\n\n git clone https://github.com/GoogleCloudPlatform/golang-samples\n\n Alternatively, [download](https://github.com/GoogleCloudPlatform/golang-samples/archive/master.zip)\n the sample as a zip file and extract it.\n2. Change to the directory that contains the sample code:\n\n cd golang-samples/appengine/go11x/helloworld/\n\nDeploying Hello World to App Engine\n-----------------------------------\n\n1. Deploy the Hello World app on App Engine by running the following\n command from the `golang-samples/appengine/go11x/helloworld` directory:\n\n gcloud app deploy\n\n2. View the live app at\n `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com`:\n\n gcloud app browse\n\nThe message **Hello, World!** is now delivered by a web server running on\nan App Engine instance.\n\n**Congratulations!** You've successfully deployed a Go web service on\nApp Engine!\n\nClean up\n--------\n\nIf you want to continue learning about App Engine, you can keep\nyour Google Cloud project and follow along with\n[Building an App](/appengine/docs/legacy/standard/go111/building-app).\n\nAlternatively, you can delete your Google Cloud project to stop billing\nfor all the resources used within that project.\n\n| **Caution** : Deleting a project has the following effects:\n|\n| - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.\n| - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.\n|\n|\n| If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects\n| can help you avoid exceeding project quota limits.\n1. In the Google Cloud console, go to the **Manage resources** page.\n\n [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)\n2. In the project list, select the project that you want to delete, and then click **Delete**.\n3. In the dialog, type the project ID, and then click **Shut down** to delete the project.\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\nNow that you have experience deploying a web service on App Engine,\nget a more in-depth introduction to Go on App Engine by reading\n[Building an App](/appengine/docs/legacy/standard/go111/building-app)."]]