Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Criar um aplicativo Go 1.11 no ambiente padrão do App Engine
ID da região
O REGION_ID é um código abreviado que o Google atribui
com base na região que você selecionou ao criar o aplicativo. O código não
corresponde a um país ou estado, ainda que alguns IDs de região sejam semelhantes
aos códigos de país e estado geralmente usados. Para apps criados após
fevereiro de 2020, o REGION_ID.r está incluído nos
URLs do App Engine. Para apps existentes criados antes dessa data, o
ID da região é opcional no URL.
Nesta página, mostramos como implantar um aplicativo básico do App Engine que exibe uma mensagem curta. Para ver uma introdução mais detalhada sobre o Go no App Engine, consulte Como criar um aplicativo.
Não há custos associados à execução deste guia. A execução deste aplicativo de amostra não excede sua cota gratuita.
Antes de começar
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.
Execute o comando a seguir para instalar o componente do gcloud, que inclui a extensão do App Engine para Go 1.11:
gcloudcomponentsinstallapp-engine-go
Locais do App Engine
O App Engine é regional. Isso significa que a infraestrutura que executa os aplicativos está em uma determinada região que é gerenciada pelo Google para estar disponível de modo redundante em todas as zonas dessa região.
Atender aos requisitos de latência, disponibilidade ou durabilidade são os principais fatores para selecionar a região de execução dos aplicativos. Geralmente, é possível
selecionar a região mais próxima dos usuários do aplicativo, mas considere os
locais em que o App Engine está disponível,
bem como os locais dos outros
produtos e serviços do Google Cloud usados pelo aplicativo. O uso de serviços
em vários locais pode afetar a latência e o preço do
aplicativo.
Não é possível alterar a região de um aplicativo depois de defini-la.
Se você já criou um aplicativo do App Engine, será possível consultar a
região dele com um dos seguintes procedimentos:
Para este guia de início rápido, você precisa conhecer a linguagem de programação Go e instalar esse ambiente (em inglês).
Fazer o download do aplicativo Hello World
Criamos um aplicativo, o Hello World, para o Go. Com ele, você tem uma ideia rápida da implantação de um aplicativo no Google Cloud Platform. Siga estas etapas para fazer o download do Hello World na máquina local.
Faça o download do aplicativo de exemplo e acesse o diretório dele:
In the project list, select the project that you
want to delete, and then click Delete.
In the dialog, type the project ID, and then click
Shut down to delete the project.
A seguir
Agora que você já sabe implantar um serviço da Web no App Engine, consulte Como criar um aplicativo para ver uma introdução mais detalhada sobre o Go no App Engine.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)."]]