From 8f38c9a8d074c1943ede6463d78b0d769331dd3e Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Sat, 1 Feb 2020 16:46:40 +0100 Subject: README: clarify where tour issues should be reported Issues with the tour code should be reported in the tracker at github.com/golang/go/issues While the 'report bug' button in the tour itself points to the issue tracker at github.com/golang/tour/issues which is the one where issues about the tour's content should be reported. Make this clear in the README. Fixes golang/go#36843 Change-Id: I7844ea1a15470fdfbc970a9485d37250a6c38779 Reviewed-on: https://go-review.googlesource.com/c/tour/+/217357 Reviewed-by: Dmitri Shuralyov --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1e0e248..17f035f 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,11 @@ Your browser should now open. If not, please visit [http://localhost:3999/](http This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html. -The main issue tracker for the tour is located at -https://github.com/golang/go/issues. Prefix your issue with "tour:" in the -subject line, so it is easy to find. +The issue tracker for the tour's code is located at https://github.com/golang/go/issues. +Prefix your issue with "x/tour:" in the subject line, so it is easy to find. + +Issues with the tour's content itself should be reported in the issue tracker +at https://github.com/golang/tour/issues. ## Deploying -- cgit v1.3 From 8ec2108c3ab568fa335edadc5cd9a2c5ab5361ec Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 8 May 2020 09:55:00 -0400 Subject: pic: document package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Effective Go¹ says every package should have a package comment, and every exported name in a package should have a doc comment. This package is mentioned in the Go tour. Let's set a good example. ¹ https://golang.org/doc/effective_go.html#commentary Change-Id: Iac561c7530fc49d5ff17c51d925151ec8319ef24 Reviewed-on: https://go-review.googlesource.com/c/tour/+/232865 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Alexander Rakoczy --- pic/pic.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pic/pic.go b/pic/pic.go index 21edae7..7f22edd 100644 --- a/pic/pic.go +++ b/pic/pic.go @@ -1,7 +1,9 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// Copyright 2011 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 pic implements functions that +// display pictures on the Go playground. package pic // import "golang.org/x/tour/pic" import ( @@ -12,7 +14,16 @@ import ( "image/png" ) -func Show(f func(int, int) [][]uint8) { +// Show displays a picture defined by the function f +// when executed on the Go Playground. +// +// f should return a slice of length dy, +// each element of which is a slice of dx +// 8-bit unsigned int. The integers are +// interpreted as bluescale values, +// where the value 0 means full blue, +// and the value 255 means full white. +func Show(f func(dx, dy int) [][]uint8) { const ( dx = 256 dy = 256 @@ -32,6 +43,8 @@ func Show(f func(int, int) [][]uint8) { ShowImage(m) } +// ShowImage displays the image m +// when executed on the Go Playground. func ShowImage(m image.Image) { var buf bytes.Buffer err := png.Encode(&buf, m) -- cgit v1.3 From 6a4383abac21758536e477d3eed0a63ba560173c Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 8 May 2020 09:57:00 -0400 Subject: pic: add a test It's hard to write a normal test because ShowImage writes to os.Stdout unconditionally. Add an example test instead. Change-Id: I52e02908e94aa212a05c058edb4f504851b5bb8d Reviewed-on: https://go-review.googlesource.com/c/tour/+/232866 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Alexander Rakoczy --- pic/pic_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pic/pic_test.go diff --git a/pic/pic_test.go b/pic/pic_test.go new file mode 100644 index 0000000..2453773 --- /dev/null +++ b/pic/pic_test.go @@ -0,0 +1,26 @@ +// Copyright 2020 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 pic_test + +import "golang.org/x/tour/pic" + +func ExampleShow() { + f := func(dx, dy int) [][]uint8 { + ss := make([][]uint8, dy) + for y := 0; y < dy; y++ { + s := make([]uint8, dx) + for x := 0; x < dx; x++ { + s[x] = uint8((x + y) / 2) + } + ss[y] = s + } + return ss + } + + pic.Show(f) + + // Output: + // IMAGE:iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAADKElEQVR4nOzVoRHAMAzAQCfX/VduxjDQk8di+mb+mTlnyKB3vYBc9K4XkIs6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANO+AAAA//9hKgMPVczXbQAAAABJRU5ErkJggg== +} -- cgit v1.3 From 0608babe047def227de553b6538ed3bd6277acff Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 8 May 2020 10:00:00 -0400 Subject: pic: don't make a string copy when writing image Previously, the entire image was encoded into a buffer, then encoded to a base64 string, which was concatenated with another string, and written to stdout in one swoop. We can do this more efficiently by writing the PNG image to a base64 encoder directly, and using buffered I/O to batch writes to stdout into moderately-sized chunks. As an added bonus, though really the main motivation for doing this optimization now, this helps avoid triggering the golang/go#38751 issue on the Go Playground. Switch to the best compression level instead of the default, reducing encoded image size at the cost of extra computation. Playground snippets need to be transferred over the network and kept in storage, so it should be a favorable trade-off. This CL was based on CL 232177. For golang/go#38751. Change-Id: I565fe538aa15910caaff98be156ac64b0d35fff4 Co-authored-by: Alexander Rakoczy Reviewed-on: https://go-review.googlesource.com/c/tour/+/232867 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Alexander Rakoczy --- pic/pic.go | 16 ++++++++++------ pic/pic_test.go | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pic/pic.go b/pic/pic.go index 7f22edd..f60ba0e 100644 --- a/pic/pic.go +++ b/pic/pic.go @@ -7,11 +7,12 @@ package pic // import "golang.org/x/tour/pic" import ( - "bytes" + "bufio" "encoding/base64" - "fmt" "image" "image/png" + "io" + "os" ) // Show displays a picture defined by the function f @@ -46,11 +47,14 @@ func Show(f func(dx, dy int) [][]uint8) { // ShowImage displays the image m // when executed on the Go Playground. func ShowImage(m image.Image) { - var buf bytes.Buffer - err := png.Encode(&buf, m) + w := bufio.NewWriter(os.Stdout) + defer w.Flush() + io.WriteString(w, "IMAGE:") + b64 := base64.NewEncoder(base64.StdEncoding, w) + err := (&png.Encoder{CompressionLevel: png.BestCompression}).Encode(b64, m) if err != nil { panic(err) } - enc := base64.StdEncoding.EncodeToString(buf.Bytes()) - fmt.Println("IMAGE:" + enc) + b64.Close() + io.WriteString(w, "\n") } diff --git a/pic/pic_test.go b/pic/pic_test.go index 2453773..0e8ccf5 100644 --- a/pic/pic_test.go +++ b/pic/pic_test.go @@ -22,5 +22,5 @@ func ExampleShow() { pic.Show(f) // Output: - // IMAGE:iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAADKElEQVR4nOzVoRHAMAzAQCfX/VduxjDQk8di+mb+mTlnyKB3vYBc9K4XkIs6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6ANM6AN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dgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgHQA0gFIByAdgA6gAh2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADSAUgHIB2AdADyxy8AAP//YSoDD5pLB7MAAAAASUVORK5CYII= } -- cgit v1.3 From 6f9d4ff994b136951d420708cd231da267653086 Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Sun, 6 Sep 2020 19:26:48 +0200 Subject: content: link to working and updated korean translation The korean translation we link to is offline due to the Go 1.9 is no longer available. error; but even before that it was quite outdated (last re-deployment was ~6 years ago). A few people have been working on an updated translation, which they deployed at go-tour-ko.appspot.com (repo github.com/golang-ko/tour). I don't speak korean but I've skimmed through it and it looks fine. Link to the new one. Updates golang/tour#1026 Fixes golang/tour#709 Fixes golang/tour#1027 Change-Id: I08edb12737a82381aeb33bb3f324e87b92936115 Reviewed-on: https://go-review.googlesource.com/c/tour/+/253337 Reviewed-by: Alberto Donizetti Reviewed-by: Dmitri Shuralyov Trust: Alberto Donizetti Run-TryBot: Dmitri Shuralyov TryBot-Result: Go Bot --- content/welcome.article | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/welcome.article b/content/welcome.article index 51aa919..9330af5 100644 --- a/content/welcome.article +++ b/content/welcome.article @@ -59,7 +59,7 @@ The tour is available in other languages: - [[https://go-tour-id2.appspot.com/][Indonesian — Bahasa Indonesia]] - [[https://go-tour-ita.appspot.com/][Italian — Italiano]] - [[https://go-tour-jp.appspot.com/][Japanese — 日本語]] -- [[https://go-tour-kr.appspot.com/][Korean — 한국어]] +- [[https://go-tour-ko.appspot.com/][Korean — 한국어]] - [[https://go-tour-ro.appspot.com/][Romanian — Română]] - [[https://go-tour-ru-ru.appspot.com/][Russian - Русский]] - [[https://gotour-es.appspot.com/][Spanish — Español]] -- cgit v1.3 From 59417492f03e0d55e544815ff163973cef919f67 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 30 Oct 2020 18:15:36 -0400 Subject: tour: redirect HTTP traffic to HTTPS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set secure to always on all handlers so that HTTP traffic is redirected to an HTTPS URL with the same path. References: • https://cloud.google.com/appengine/docs/standard/go/application-security#https_requests • https://cloud.google.com/appengine/docs/standard/go/config/appref#handlers_secure For golang/go#42281. Change-Id: Ic03e01d5858e1e5b8ae1b523ab34d970e1403ce0 Reviewed-on: https://go-review.googlesource.com/c/tour/+/266817 Trust: Dmitri Shuralyov Reviewed-by: Alexander Rakoczy Reviewed-by: Carlos Amedee --- app.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.yaml b/app.yaml index 5ba09d0..aab2f02 100644 --- a/app.yaml +++ b/app.yaml @@ -15,9 +15,10 @@ env_variables: default_expiration: "7d" +handlers: + # Keep these static file handlers in sync with local.go. # They're here for improved latency across global regions. -handlers: - url: /favicon.ico static_files: static/img/favicon.ico upload: static/img/favicon.ico @@ -28,3 +29,9 @@ handlers: - url: /static static_dir: static secure: always + +# This is here to redirect all HTTP traffic to an HTTPS URL +# with the same path. +- url: /.* + script: auto + secure: always -- cgit v1.3 From 4bb7d986198daef2a80e976e7a3576204332e0ba Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 30 Oct 2020 18:16:31 -0400 Subject: tour: update to the App Engine Go 1.14 runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reference: • https://cloud.google.com/appengine/docs/standard/go/runtime Change-Id: I46b87098ed04c9c5d9f84193c9d72f9d30a59233 Reviewed-on: https://go-review.googlesource.com/c/tour/+/266818 Trust: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov TryBot-Result: Go Bot Reviewed-by: Alexander Rakoczy Reviewed-by: Carlos Amedee --- app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.yaml b/app.yaml index aab2f02..9de61cf 100644 --- a/app.yaml +++ b/app.yaml @@ -1,5 +1,5 @@ service: tour -runtime: go112 +runtime: go114 env_variables: GOLANGORG_CHECK_COUNTRY: true -- cgit v1.3 From 004403599411fcd726b1e58cd0199083507d2047 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Thu, 3 Dec 2020 18:17:21 -0500 Subject: README.md: add badge to pkg.go.dev Change-Id: Ifa508b83e5b02db6a3d5a173879fab17bdd4a50d Reviewed-on: https://go-review.googlesource.com/c/tour/+/275196 Run-TryBot: Julie Qiu TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov Trust: Julie Qiu --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17f035f..a186565 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Go Tour +[![Go Reference](https://pkg.go.dev/badge/golang.org/x/tour.svg)](https://pkg.go.dev/golang.org/x/tour) + A Tour of Go is an introduction to the Go programming language. Visit https://tour.golang.org to start the tour. @@ -36,7 +38,7 @@ this repository, see https://golang.org/doc/contribute.html. The issue tracker for the tour's code is located at https://github.com/golang/go/issues. Prefix your issue with "x/tour:" in the subject line, so it is easy to find. -Issues with the tour's content itself should be reported in the issue tracker +Issues with the tour's content itself should be reported in the issue tracker at https://github.com/golang/tour/issues. ## Deploying -- cgit v1.3 From b72029adf3393d3635828fedcddd5ae7053d3250 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sat, 13 Feb 2021 17:41:38 -0500 Subject: tour: build snippets in module mode We want to start building snippets in module mode rather than legacy legacy GOPATH mode, to make tour work well when there's no tour code in GOPATH/src and to be more future-proof. Building in module mode means we need to specify a go.mod file to use for each snippet. The tour web UI design predates the module mode and its go.mod files. Txtar-based multi-file support was added to the playground (that the tour uses for executing snippets) in golang.org/issue/32040, but the web UI hasn't been updated to have first-class separate