Skip to content

Commit b593c13

Browse files
committed
tour: fix go.mod module path
The supporting packages (pic, reader, tree, wc) are still in golang.org/x/tour, so delete these copies. Fix the remaining references in local.go to use golang.org/x/website/tour instead of golang.org/x/tour to find the content files. While we are here, make go test ./... considerably faster by parallelizing TestContent. For golang/go#46501. Change-Id: Ia80161830f5f2f87fb6e39a0ee39c4b176fb425b Reviewed-on: https://go-review.googlesource.com/c/website/+/324395 Trust: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Website-Publish: Russ Cox <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 52dfb42 commit b593c13

File tree

11 files changed

+22
-254
lines changed

11 files changed

+22
-254
lines changed

tour/content/content_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
"path/filepath"
1515
"strings"
1616
"testing"
17+
18+
// Keep golang.org/x/tour in our go.mod require list for use during test.
19+
_ "golang.org/x/tour/wc"
1720
)
1821

1922
// Test that all the .go files inside the content file build
@@ -38,9 +41,12 @@ func TestContent(t *testing.T) {
3841
if filepath.Base(path) == "content_test.go" {
3942
return nil
4043
}
41-
if err := testSnippet(t, path, scratch); err != nil {
42-
t.Errorf("%v: %v", path, err)
43-
}
44+
t.Run(path, func(t *testing.T) {
45+
t.Parallel()
46+
if err := testSnippet(t, path, scratch); err != nil {
47+
t.Errorf("%v: %v", path, err)
48+
}
49+
})
4450
return nil
4551
})
4652
if err != nil {

tour/go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module golang.org/x/tour
1+
module golang.org/x/website/tour
22

33
go 1.11
44

5-
require golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee
5+
require (
6+
golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee
7+
golang.org/x/tour v0.1.0
8+
)

tour/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
2323
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
2424
golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee h1:qoXIhA/wpnHg2z8RiA/rZb66+iiULmKyO9olVAU+GfU=
2525
golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
26+
golang.org/x/tour v0.1.0 h1:OWzbINRoGf1wwBhKdFDpYwM88NM0d1SL/Nj6PagS6YE=
27+
golang.org/x/tour v0.1.0/go.mod h1:DUZC6G8mR1AXgXy73r8qt/G5RsefKIlSj6jBMc8b9Wc=
2628
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2729
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2830
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=

tour/gotour/main.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

tour/local.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ import (
2323
"time"
2424

2525
"golang.org/x/tools/playground/socket"
26-
27-
// Imports so that go build/install automatically installs them.
28-
_ "golang.org/x/tour/pic"
29-
_ "golang.org/x/tour/tree"
30-
_ "golang.org/x/tour/wc"
3126
)
3227

3328
const (
@@ -58,20 +53,20 @@ func isRoot(path string) bool {
5853
//
5954
// TODO: Delete after Go 1.17 is out and we can just use embed; see CL 291849.
6055
func findRoot() (string, bool) {
61-
// Try finding the golang.org/x/tour package in the
56+
// Try finding the golang.org/x/website/tour package in the
6257
// legacy GOPATH mode workspace or in build list.
63-
p, err := build.Import("golang.org/x/tour", "", build.FindOnly)
58+
p, err := build.Import("golang.org/x/website/tour", "", build.FindOnly)
6459
if err == nil && isRoot(p.Dir) {
6560
return p.Dir, true
6661
}
6762
// If that didn't work, perhaps we're not inside any module
6863
// and the binary was built in module mode (e.g., 'go install
69-
// golang.org/x/tour@latest' or 'go get golang.org/x/tour'
64+
// golang.org/x/website/tour@latest' or 'go get golang.org/x/website/tour'
7065
// outside a module).
7166
// In that's the case, find out what version it is,
7267
// and access its content from the module cache.
7368
if info, ok := debug.ReadBuildInfo(); ok &&
74-
info.Main.Path == "golang.org/x/tour" &&
69+
info.Main.Path == "golang.org/x/website/tour" &&
7570
info.Main.Replace == nil &&
7671
info.Main.Version != "(devel)" {
7772
// Make some assumptions for brevity:
@@ -80,7 +75,7 @@ func findRoot() (string, bool) {
8075
// • the version isn't "(devel)"
8176
// They should hold for the use cases we care about, until this
8277
// entire mechanism is obsoleted by file embedding.
83-
out, execError := exec.Command("go", "mod", "download", "-json", "--", "golang.org/x/tour@"+info.Main.Version).Output()
78+
out, execError := exec.Command("go", "mod", "download", "-json", "--", "golang.org/x/website/tour@"+info.Main.Version).Output()
8479
var tourRoot struct{ Dir string }
8580
jsonError := json.Unmarshal(out, &tourRoot)
8681
if execError == nil && jsonError == nil && isRoot(tourRoot.Dir) {

tour/pic/pic.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

tour/pic/pic_test.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

tour/reader/validate.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

tour/tour.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
package main // import "golang.org/x/tour"
5+
package main // import "golang.org/x/website/tour"
66

77
import (
88
"bytes"

tour/tree/tree.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

tour/wc/wc.go

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)