Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Hello Go on App Engine

Learning objectives
  • Build a skeleton for your Go App Engine web application.

First, you need to create the skeleton for your new App Engine application.

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

google_appengine/
goplus/
    app.yaml
    hello.go
  1. Download and unzip the Go App Engine SDK
  2. Install Mercurial
  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
    
    handlers:
      - url: /.*
        script: _go_app
    
  5. Inside the goplus directory, create a file named hello.go with the following contents:
    package goplus
    
    import (
    	"fmt"
    	"net/http"
    )
    
    // 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 0.0.0.0 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+

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.