From f2b3bb0049976dc77ab5211f90f5c5e9f1d5b4c1 Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Mon, 31 Jul 2017 11:02:19 -0700 Subject: [PATCH] cmd/getgo: fix builds A couple fixes: * Disable integration tests in short mode. * Remove import of "google.golang.org/appengine" package. App Engine has two ways to create an app: as a main package and calling appengine.Main(), and as any regular Go package with handlers registered in init(). Change-Id: Ib416111786c1c86cf428d91c60dc406c251d3ca1 Reviewed-on: https://go-review.googlesource.com/52211 Run-TryBot: Chris Broadfoot TryBot-Result: Gobot Gobot Reviewed-by: Jaana Burcu Dogan --- cmd/getgo/main_test.go | 5 +++++ cmd/getgo/server/main.go | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/getgo/main_test.go b/cmd/getgo/main_test.go index 9da726e4..932a7397 100644 --- a/cmd/getgo/main_test.go +++ b/cmd/getgo/main_test.go @@ -31,6 +31,11 @@ func init() { // TestMain creates a getgo command for testing purposes and // deletes it after the tests have been run. func TestMain(m *testing.M) { + if os.Getenv("GOGET_INTEGRATION") == "" { + fmt.Fprintln(os.Stderr, "main_test: Skipping integration tests with GOGET_INTEGRATION unset") + return + } + args := []string{"build", "-tags", testbin, "-o", testbin + exeSuffix} out, err := exec.Command("go", args...).CombinedOutput() if err != nil { diff --git a/cmd/getgo/server/main.go b/cmd/getgo/server/main.go index 0bd33377..b5995065 100644 --- a/cmd/getgo/server/main.go +++ b/cmd/getgo/server/main.go @@ -4,15 +4,13 @@ // Command server serves get.golang.org, redirecting users to the appropriate // getgo installer based on the request path. -package main +package server import ( "fmt" "net/http" "strings" "time" - - "google.golang.org/appengine" ) const ( @@ -30,9 +28,8 @@ var stringMatch = map[string]string{ "Darwin": macInstaller, } -func main() { +func init() { http.HandleFunc("/", handler) - appengine.Main() } func handler(w http.ResponseWriter, r *http.Request) {