Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created November 18, 2015 03:23

Revisions

  1. jonathaningram created this gist Nov 18, 2015.
    20 changes: 20 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    Deploy it for prod:

    ```
    $ goapp deploy .
    ```

    Go to http://gae-test-1133.appspot.com/ (or replace with <your app id>) and notice that only one the runtime `HELLO` is the correct value: `prefetched: "", runtime: "hello world"`

    Now run it in dev:

    ```
    $ goapp serve .
    ```

    Go to http://localhost:8080 and both values are right: `prefetched: "hello world", runtime: "hello world"`

    ```
    $ goapp version
    go version go1.4.2 (appengine-1.9.28) darwin/amd64
    ```
    21 changes: 21 additions & 0 deletions app.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    package main

    import (
    "fmt"
    "log"
    "net/http"
    "os"
    )

    var hello string

    func init() {
    hello = os.Getenv("HELLO")
    log.Println(hello)

    http.Handle("/", http.HandlerFunc(handle))
    }

    func handle(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte(fmt.Sprintf("prefetched: %q, runtime: %q", hello, os.Getenv("HELLO"))))
    }
    12 changes: 12 additions & 0 deletions app.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    application: gae-test-1133 # or <your app id>
    module: default
    version: 1
    runtime: go
    api_version: go1

    includes:
    - env.yaml

    handlers:
    - url: /.*
    script: _go_app
    2 changes: 2 additions & 0 deletions env.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    env_variables:
    HELLO: 'hello world'