Hello Go on App Engine

In this lesson, you will build a skeleton for your Go App Engine web application.

At the end of this section, your working directory should look like this:

  1. Download and unzip the Go App Engine SDK

  2. Create or select a Cloud Platform project in the Cloud Platform Console and then ensure that project includes an App Engine application:

    Go to App Engine

    The Dashboard opens if an App Engine application already exists in your project. Otherwise, you are prompted to choose the region where you want your App Engine application located.

  3. Note the ID of the project, because you'll need it later.

  4. Create a new directory named goplus in your working directory. This directory will contain your App Engine application files.

  5. Inside the goplus directory, create a file named app.yaml with the following contents. This file contains your App Engine application configuration.

    application: goplus
    version: 1
    runtime: go
    api_version: go1
      - url: /.*
        script: _go_app

  6. Inside the goplus directory, create a file named hello.go with the following contents:

    package goplus
    import (
    // init is called before the application starts.
    func init() {
    	// Register a handler for /hello URLs.
    	http.HandleFunc("/", hello)
    // hello is an HTTP handler that prints "Hello Gopher!"
    func hello(w http.ResponseWriter, r *http.Request) {
    	fmt.Fprint(w, "Hello, Gopher!")

  7. Start the development server by running dev_appserver.py (located in the google_appengine directory) on the command line, with the directory of your application as its first argument.

    /path/to/google_appengine/dev_appserver.py goplus

    You can use the -a option to bind the development server to all your available IP addresses.

  8. Open http://localhost:8080 in your browser.

You should see: Hello Gopher!

Next step: Hello Google+

Send feedback about...

Go on App Engine