1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:54:49 -07:00

cmd/getgo/server: update to go112 GAE runtime

Change-Id: Ib8a301da7ce32ece3fe15d7cbecddeaf380ec43a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/191377
Reviewed-by: Katie Hockman <katie@golang.org>
This commit is contained in:
Andrew Bonventre 2019-08-22 14:56:02 -04:00
parent 71f556f074
commit b1e2c8edce
3 changed files with 40 additions and 8 deletions

View File

@ -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

View File

@ -1,7 +1,2 @@
runtime: go
runtime: go112
service: get
api_version: go1
handlers:
- url: /.*
script: _go_app

View File

@ -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) {