Quickstart for Go App Engine Standard Environment

This quickstart shows you how to create a small App Engine application that displays a short message.

Before you begin

Before running this sample, you must install the App Engine SDK for Go:

Download the SDK

Download the Hello World app

We've created a simple Hello World app for Go so you can quickly get a feel for deploying an app to Google Cloud Platform. Follow these steps to download Hello World to your local machine.

  1. Clone the Hello World sample app repository to your local machine in a directory called helloworld:

    git clone -b part1-helloworld https://github.com/GoogleCloudPlatform/appengine-guestbook-go.git helloworld
  2. Then go to the directory that contains the sample code:

    cd helloworld

Alternatively, you can download the sample as a zip file and extract it into a directory called helloworld.

Test the application

Test the application using the local development server (dev_appserver.py), which is included with the SDK.

  1. From helloworld directory, run the following command to compile your app and start the development server:

    goapp serve app.yaml

    The development server is now running, listening for requests on port 8080.

    Something go wrong? You can run goapp help serve or see Using the Local Development Server for more information.

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

Make a change

The development server watches for changes in your project files. As you update your source, it recompiles them and relaunches your local app. There's no need to restart goapp.

  1. Try it now: leave the development server running, then edit hello.go 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, you will need the ID of your Cloud Platform project.

  1. Create a new Cloud Platform project and App Engine application using the Cloud Platform Console:
    Go to App Engine

    When prompted, select the region where you want your App Engine application located. After your App Engine application is created, the Dashboard opens.

  2. Note the project ID that you created above.
  3. Upload your application to App Engine by running the following command from the `helloworld` directory where your `app.yaml` file is located:
    goapp deploy -application [YOUR_PROJECT_ID] -version [YOUR_VERSION_ID] .
  4. Your app is now deployed and ready to serve traffic at http://[YOUR_PROJECT_ID].appspot.com/.

Congratulations! You have completed this quickstart.

Clean up

To avoid incurring charges to your Cloud Platform project, you can delete your project to stop billing for all resources within the project.

  1. In the Cloud Platform Console, go to the Projects page.

    Go to the Projects page

  2. In the project list, select the project you want to delete and click Delete project. After selecting the checkbox next to the project name, click
      Delete project
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

What's next

Hello World code review

Hello World is the simplest possible App Engine app: it contains only one service, has only one version, and all of the code is located within the app's root directory. This section describes each of the app files in detail.

This Go package responds to any request by sending a response containing the message Hello, world!.

package hello

import (

func init() {
    http.HandleFunc("/", handler)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello, world!")


The app.yaml configuration file tells the App Engine service which runtime to use and which URLs should be handled by our Go program.

runtime: go
api_version: go1

- url: /.*
  script: _go_app

From top to bottom, this configuration file says the following about this application:

  • This code runs in the go runtime environment, with API version go1.
  • Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the Go program. The _go_app value is a magic string recognized by the local development server; it is ignored by the production App Engine servers.

The syntax of this file is YAML. For a complete list of configuration options, see the Go Application Configuration page.

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 that teaches you how to create an application that uses the entire platform, not just App Engine, check out our "Creating a Guestbook" quickstart in which you expand this simple application to become a fully-fledged Guestbook application that lets authenticated Google accounts post messages to a public page.

Learn more about App Engine standard environment

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

Send feedback about...

App Engine standard environment for Go