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
- Download and unzip the Go App Engine SDK
- Install Mercurial
-
Create a new directory named
goplus
in your working directory. This directory will contain your App Engine application files. -
Inside the
goplus
directory, create a file namedapp.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
-
Inside the
goplus
directory, create a file namedhello.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!") }
-
Start the development server by running
dev_appserver.py
(located in thegoogle_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. - Open http://localhost:8080 in your browser.
You should see:
Hello Gopher!
Next step: Hello Google+