Quickstart for Go 1.9 on App Engine Standard Environment

This quickstart shows how to deploy a sample app on App Engine. If you want to learn about coding an app for App Engine, see Building an App.


There are no costs associated with running this guide. Running this sample app alone does not exceed your free quota.

Before you begin

Before running and deploying this quickstart, install the Cloud SDK and then set up a GCP project for App Engine:

  1. Download and install Cloud SDK:

    Download the SDK

    Note: If you already have the Cloud SDK installed, update it by running the following command:

    gcloud components update
  2. Create a new project:

    gcloud projects create [YOUR_PROJECT_ID] --set-as-default

    Verify the project was created:

    gcloud projects describe [YOUR_PROJECT_ID]

    You see project details that might look like the following:

    createTime: year-month-hour
    lifecycleState: ACTIVE
    name: project-name
    id: '433637338589'
    type: organization
    projectId: project-name-id
    projectNumber: 499227785679
  3. Initialize your App Engine app with your project and choose its region:

    gcloud app create --project=[YOUR_PROJECT_ID]

    When prompted, select the region where you want your App Engine application located.

  4. Install the following prerequisites:

    • Run the following command to install the gcloud component that includes the App Engine extension for Go 1.9:

      gcloud components install app-engine-go

App Engine locations

App Engine is regional, which means the infrastructure that runs your apps is located in a specific region and is managed by Google to be redundantly available across all the zones within that region.

Meeting your latency, availability, or durability requirements are primary factors for selecting the region where your apps are run. You can generally select the region nearest to your app's users but you should consider the location of the other GCP products and services that are used by your app. Using services across multiple locations can affect your app's latency as well as pricing.

App Engine is available in the following regions:

  • northamerica-northeast1 (Montréal)
  • us-central (Iowa)
  • us-west2 (Los Angeles)
  • us-east1 (South Carolina)
  • us-east4 (Northern Virginia)
  • southamerica-east1 (São Paulo)
  • europe-west (Belgium)
  • europe-west2 (London)
  • europe-west3 (Frankfurt)
  • europe-west6 (Zürich)
  • asia-northeast1 (Tokyo)
  • asia-northeast2 (Osaka)
  • asia-east2 (Hong Kong)
  • asia-south1 (Mumbai)
  • australia-southeast1 (Sydney)

You cannot change an app's region after you set it.

If you already created an App Engine application, you can view the region by running the gcloud app describe command or opening the App Engine Dashboard in the GCP Console. The region of your App Engine application is listed under http://[YOUR_PROJECT_ID].appspot.com.

This quickstart assumes that you are familiar with the Go programming language and that you have installed Go.

Download the Hello World app

We've created a simple Hello World app for Go so that you can quickly get a feel for deploying an app to Google Cloud Platform.

  1. Download the Hello World sample app repository and its dependencies to a directory called helloworld on your local machine:

    go get -u -d github.com/GoogleCloudPlatform/golang-samples/appengine/helloworld/...
  2. Change to the helloworld directory:

    cd $GOPATH/src/github.com/GoogleCloudPlatform/golang-samples/appengine/helloworld

Alternatively, you can download the sample as a .zip file.

Test the application

Test the application using the local development server, which is included with the SDK.

  1. From within the helloworld directory where the app's app.yaml configuration file is located, run the dev_appserver.py command to compile your app and then start the local development server:

      dev_appserver.py app.yaml

    The local development server is now running and listening for requests on port 8080. Something go wrong?

  2. Visit http://localhost:8080/ in your web browser to see the app in action.

Running the local development server (dev_appserver.py)

To run the local development server, you can either run dev_appserver.py by specifying the full directory path or you can add dev_appserver.py to your PATH environment variable:

  • If you installed the original App Engine SDK, the tool is located at:

  • If you installed the Google Cloud SDK, the tool is located at:


    Tip: To add the Google Cloud SDK tools to your PATH environment variable and enable command-completion in your shell, you can run:


For more information about running the local development server including how to change the port number, see the Local Development Server reference.

Make a change

The local development server watches for changes in your project files. As you update your source code, your app is recompiled and launched.

  1. Try it now: Leave the local development server running and then try editing the hello.go file to change Hello, world! to something else.
  2. Reload http://localhost:8080/ to see the change.

Deploy your app

To deploy your app to App Engine, run the following command from within the root directory of your application where the app.yaml file is located:

gcloud app deploy

Learn about the optional flags.

Common gcloud command flags

  • Include the --version flag to specify an ID that uniquely identifies that version of your app, otherwise one is generated for you. Example: --version [YOUR_VERSION_ID]
  • Include the --project flag to specify an alternate GCP project ID to what you initialized as the default in the gcloud tool. Example: --project [YOUR_PROJECT_ID]


gcloud app deploy --version pre-prod-5 --project my-sample-app

To learn more about deploying your app from the command line, see Deploying a Go 1.9 App . For a list of all the command flags, see the gcloud app deploy reference.

View your application

To launch your browser and view the app at http://[YOUR_PROJECT_ID].appspot.com, run the following command:

gcloud app browse


You have completed this quickstart.

See the following sections for information about cleaning up as well as links to the possible next steps that you can take.

Clean up

If you enabled billing for your project, you can delete your GCP project to stop billing for all the resources used within that project.

  1. En la GCP Console, dirígete a la página Proyectos.

    Ir a la página Proyectos

  2. En la lista de proyectos, selecciona el proyecto que deseas borrar y haz clic en Borrar.
  3. En el cuadro de diálogo, escribe el ID del proyecto y, luego, haz clic en Cerrar para borrar el proyecto.

What's next

Learn the whole platform

Now that you know what it's like to develop and deploy App Engine apps, you can stretch out and see the rest of Google Cloud Platform. For a guided walkthrough which teaches you how to create an application that uses more of the Cloud platform, not just App Engine, check out our "Building an App" guide. The guide builds on what you've learned from this quickstart, teaching you how to deploy a simple blog application where users can upload and store posts.

Learn more about App Engine standard environment

Here are some topics to help you to continue learning about App Engine:

¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...

App Engine standard environment for Go