From 5807c4fa28aba30e78d2ef679bb99cd9fe45c9b9 Mon Sep 17 00:00:00 2001 From: Andrew Bonventre Date: Fri, 12 Oct 2018 11:18:43 -0400 Subject: [PATCH] tour: make the tour deployable on App Engine again Move the main Go files into the same directory as the app.yaml file. This changes the command location to be at golang.org/x/tour instead of golang.org/x/tour/gotour. Add a placeholder command in gotour so that those who use the previous installation command will know to use the new one and it won't just seem like it has vanished. Also update the documentation to take into account that the tour is no longer distributed with releases as of golang.org/cl/131156 Fixes golang/go#28163 Change-Id: I60737f0cfaa93d12902a75fbc0924d96672a8c9b Reviewed-on: https://go-review.googlesource.com/c/141857 Run-TryBot: Andrew Bonventre TryBot-Result: Gobot Gobot Reviewed-by: Dmitri Shuralyov --- README.md | 11 ++----- app.yaml | 5 ++-- gotour/appengine.go => appengine.go | 0 content/welcome.article | 45 ++++++++++++----------------- gotour/fmt.go => fmt.go | 0 gotour/main.go | 15 ++++++++++ gotour/local.go => local.go | 2 +- gotour/tour.go => tour.go | 2 +- 8 files changed, 41 insertions(+), 39 deletions(-) rename gotour/appengine.go => appengine.go (100%) rename gotour/fmt.go => fmt.go (100%) create mode 100644 gotour/main.go rename gotour/local.go => local.go (98%) rename gotour/tour.go => tour.go (99%) diff --git a/README.md b/README.md index 3db4f9a..0f4cce8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,11 @@ A Tour of Go is an introduction to the Go programming language. -The easiest way to install the tour locally is to install -[a binary release of Go](https://golang.org/dl/) and then run: - - $ go tool tour - -To install the tour from source, first +To install the tour from source, first [set up a workspace](https://golang.org/doc/code.html) and then run: - $ go get golang.org/x/tour/gotour + $ go get golang.org/x/tour -This will place a `gotour` binary in your workspace's `bin` directory. +This will place a `tour` binary in your workspace's `bin` directory. Unless otherwise noted, the go-tour source files are distributed under the BSD-style license found in the LICENSE file. diff --git a/app.yaml b/app.yaml index dfff2d5..e6552eb 100644 --- a/app.yaml +++ b/app.yaml @@ -1,5 +1,4 @@ -application: go-tour -version: 1 +service: tour runtime: go api_version: go1 @@ -7,7 +6,7 @@ default_expiration: "7d" handlers: -# Keep these static file handlers in sync with gotour/local.go. +# Keep these static file handlers in sync with local.go. - url: /favicon.ico static_files: static/img/favicon.ico upload: static/img/favicon.ico diff --git a/gotour/appengine.go b/appengine.go similarity index 100% rename from gotour/appengine.go rename to appengine.go diff --git a/content/welcome.article b/content/welcome.article index 791b73c..6df361f 100644 --- a/content/welcome.article +++ b/content/welcome.article @@ -70,48 +70,41 @@ The tour is available in other languages: Click the [[javascript:highlightAndClick(".next-page")]["next"]] button or type `PageDown` to continue. #appengine: * Go offline -#appengine: +#appengine: #appengine: This tour is also available as a stand-alone program that you can use #appengine: without access to the internet. -#appengine: +#appengine: #appengine: The stand-alone tour is faster, as it builds and runs the code samples #appengine: on your own machine. -#appengine: -#appengine: To run the tour locally first -#appengine: [[https://golang.org/dl/][download and install Go]] -#appengine: then start the tour from the command line: -#appengine: -#appengine: go tool tour -#appengine: -#appengine: Or, you can install and run this tour manually if you have any trouble -#appengine: running the above command: -#appengine: -#appengine: go get golang.org/x/tour/gotour -#appengine: gotour -#appengine: +#appengine: +#appengine: To run the tour locally install and run the tour binary: +#appengine: +#appengine: go get golang.org/x/tour +#appengine: tour +#appengine: #appengine: The tour program will open a web browser displaying #appengine: your local version of the tour. -#appengine: +#appengine: #appengine: Or, of course, you can continue to take the tour through this web site. #appengine: * The Go Playground -#appengine: +#appengine: #appengine: This tour is built atop the [[https://play.golang.org/][Go Playground]], a #appengine: web service that runs on [[https://golang.org/][golang.org]]'s servers. -#appengine: +#appengine: #appengine: The service receives a Go program, compiles, links, and runs the program inside #appengine: a sandbox, then returns the output. -#appengine: -#appengine: There are limitations to the programs that can be run in the playground: -#appengine: +#appengine: +#appengine: There are limitations to the programs that can be run in the playground: +#appengine: #appengine: - In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output. -#appengine: -#appengine: - There are also limits on execution time and on CPU and memory usage, and the program cannot access external network hosts. -#appengine: +#appengine: +#appengine: - There are also limits on execution time and on CPU and memory usage, and the program cannot access external network hosts. +#appengine: #appengine: The playground uses the latest stable release of Go. -#appengine: +#appengine: #appengine: Read "[[https://blog.golang.org/playground][Inside the Go Playground]]" to learn more. -#appengine: +#appengine: #appengine: .play welcome/sandbox.go * Congratulations diff --git a/gotour/fmt.go b/fmt.go similarity index 100% rename from gotour/fmt.go rename to fmt.go diff --git a/gotour/main.go b/gotour/main.go new file mode 100644 index 0000000..b0b2d50 --- /dev/null +++ b/gotour/main.go @@ -0,0 +1,15 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "io" + "os" +) + +func main() { + io.WriteString(os.Stderr, "golang.org/x/tour/gotour has moved to golang.org/x/tour\n") + os.Exit(1) +} diff --git a/gotour/local.go b/local.go similarity index 98% rename from gotour/local.go rename to local.go index c51010f..170dcf0 100644 --- a/gotour/local.go +++ b/local.go @@ -106,7 +106,7 @@ func main() { origin := &url.URL{Scheme: "http", Host: host + ":" + port} http.Handle(socketPath, socket.NewHandler(origin)) - // Keep these static file handlers in sync with ../app.yaml. + // Keep these static file handlers in sync with app.yaml. static := http.FileServer(http.Dir(root)) http.Handle("/content/img/", static) http.Handle("/static/", static) diff --git a/gotour/tour.go b/tour.go similarity index 99% rename from gotour/tour.go rename to tour.go index 0d6ea3b..1a74285 100644 --- a/gotour/tour.go +++ b/tour.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package main // import "golang.org/x/tour/gotour" +package main // import "golang.org/x/tour" import ( "bytes"