tour: look for content in x/website module
As of CL 323897, the tour command and its static content are
contained in a module with a slightly different module path.
Update findRoot accordingly so it looks in the right place.
Updates golang/go#44243.
Change-Id: I5c979789440464ca3f9f99799bcc8e73db0769a3
Reviewed-on: https://go-review.googlesource.com/c/website/+/334969
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/tour/local.go b/tour/local.go
index f59edfa..5268814 100644
--- a/tour/local.go
+++ b/tour/local.go
@@ -64,10 +64,10 @@
// and the binary was built in module mode (e.g., 'go install
// golang.org/x/website/tour@latest' or 'go get golang.org/x/website/tour'
// outside a module).
- // In that's the case, find out what version it is,
+ // If that's the case, find out what version it is,
// and access its content from the module cache.
if info, ok := debug.ReadBuildInfo(); ok &&
- info.Main.Path == "golang.org/x/website/tour" &&
+ info.Main.Path == "golang.org/x/website" &&
info.Main.Replace == nil &&
info.Main.Version != "(devel)" {
// Make some assumptions for brevity:
@@ -76,11 +76,12 @@
// • the version isn't "(devel)"
// They should hold for the use cases we care about, until this
// entire mechanism is obsoleted by file embedding.
- out, execError := exec.Command("go", "mod", "download", "-json", "--", "golang.org/x/website/tour@"+info.Main.Version).Output()
- var tourRoot struct{ Dir string }
- jsonError := json.Unmarshal(out, &tourRoot)
- if execError == nil && jsonError == nil && isRoot(tourRoot.Dir) {
- return tourRoot.Dir, true
+ out, execError := exec.Command("go", "mod", "download", "-json", "--", "golang.org/x/website@"+info.Main.Version).Output()
+ var websiteRoot struct{ Dir string }
+ jsonError := json.Unmarshal(out, &websiteRoot)
+ tourDir := filepath.Join(websiteRoot.Dir, "tour")
+ if execError == nil && jsonError == nil && isRoot(tourDir) {
+ return tourDir, true
}
}
return "", false