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 a Google Cloud Platform Console project, which creates your App Engine project and you will use later to configure your API credentials.

    1. In Google Cloud Platform Console, click Create Project.
    2. Choose a project name and ID. The project ID becomes part of your App Engine project URL: http://YOUR_PROJECT_ID.appspot.com. You will use this ID in later lessons.
  3. Create a new directory named goplus in your working directory. This directory will contain your App Engine application files.

  4. 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

  5. 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!")

  6. 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.

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

You should see: Hello Gopher!

Next step: Hello Google+

Send feedback about...

App Engine standard environment for Go