diff --git a/cmd/getgo/server/.gcloudignore b/cmd/getgo/server/.gcloudignore new file mode 100644 index 0000000000..199e6d9f2f --- /dev/null +++ b/cmd/getgo/server/.gcloudignore @@ -0,0 +1,25 @@ +# This file specifies files that are *not* uploaded to Google Cloud Platform +# using gcloud. It follows the same syntax as .gitignore, with the addition of +# "#!include" directives (which insert the entries of the given .gitignore-style +# file at that point). +# +# For more information, run: +# $ gcloud topic gcloudignore +# +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or files +# from your .gitignore file, remove the corresponding line +# below: +.git +.gitignore + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +# Test binary, build with `go test -c` +*.test +# Output of the go coverage tool, specifically when used with LiteIDE +*.out \ No newline at end of file diff --git a/cmd/getgo/server/app.yaml b/cmd/getgo/server/app.yaml index 0502c4e04c..5c47312ef1 100644 --- a/cmd/getgo/server/app.yaml +++ b/cmd/getgo/server/app.yaml @@ -1,7 +1,2 @@ -runtime: go +runtime: go112 service: get -api_version: go1 - -handlers: -- url: /.* - script: _go_app diff --git a/cmd/getgo/server/main.go b/cmd/getgo/server/main.go index 9679b3bb6a..bdb0f70cf4 100644 --- a/cmd/getgo/server/main.go +++ b/cmd/getgo/server/main.go @@ -4,11 +4,12 @@ // Command server serves get.golang.org, redirecting users to the appropriate // getgo installer based on the request path. -package server +package main import ( "fmt" "net/http" + "os" "strings" "time" ) @@ -28,8 +29,19 @@ var stringMatch = map[string]string{ "Darwin": macInstaller, } -func init() { +func main() { http.HandleFunc("/", handler) + + port := os.Getenv("PORT") + if port == "" { + port = "8080" + fmt.Printf("Defaulting to port %s", port) + } + + fmt.Printf("Listening on port %s", port) + if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil { + fmt.Fprintf(os.Stderr, "http.ListenAndServe: %v", err) + } } func handler(w http.ResponseWriter, r *http.Request) {