Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created November 18, 2015 03:23
Show Gist options
  • Save jonathaningram/c8385e097c6ffd51d0cc to your computer and use it in GitHub Desktop.
Save jonathaningram/c8385e097c6ffd51d0cc to your computer and use it in GitHub Desktop.
Discrepancy between GAE Go SDK in dev and prod with regards to os.Getenv and env_variables

Deploy it for prod:

$ goapp deploy . 

Go to http://gae-test-1133.appspot.com/ (or replace with ) 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
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"))))
}
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
env_variables:
HELLO: 'hello world'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment