aboutsummaryrefslogtreecommitdiff
path: root/cmd/pkgsite
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-09-03 09:08:51 -0400
committerJonathan Amsterdam <jba@google.com>2021-09-03 18:33:44 +0000
commitea5d40fb386ffd6be6d6b0a1a80843051b3bc2bd (patch)
tree37829ed5161f594d20aa49fb31bed8bb4608d8d7 /cmd/pkgsite
parent6a8d217e636e9e4d730b3c63f1be050f61c75950 (diff)
downloadgo-x-pkgsite-ea5d40fb386ffd6be6d6b0a1a80843051b3bc2bd.tar.xz
cmd/pkgsite: use local Go repo clone
Add the -gorepo flag, which lets the user specify a local clone of the Go repo. This can save a little time serving standard library pages. Change-Id: Ic8f436b8ba3494dc51db7593b20613724faab9e5 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347549 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'cmd/pkgsite')
-rw-r--r--cmd/pkgsite/main.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/pkgsite/main.go b/cmd/pkgsite/main.go
index 3aa7d41d..54872f84 100644
--- a/cmd/pkgsite/main.go
+++ b/cmd/pkgsite/main.go
@@ -24,6 +24,11 @@
// You can still provide modules on the local filesystem by listing their paths:
//
// pkgsite -static ~/repos/pkgsite/static -cache -proxy ~/repos/cue some/other/module
+//
+// Although standard library packages will work by default, the docs can take a
+// while to appear the first time because the Go repo must be cloned and
+// processed. If you clone the repo yourself (https://go.googlesource.com/go),
+// provide its location with the -gorepo flag to save a little time.
package main
import (
@@ -46,6 +51,7 @@ import (
"golang.org/x/pkgsite/internal/middleware"
"golang.org/x/pkgsite/internal/proxy"
"golang.org/x/pkgsite/internal/source"
+ "golang.org/x/pkgsite/internal/stdlib"
)
const defaultAddr = "localhost:8080" // default webserver address
@@ -57,6 +63,7 @@ var (
useCache = flag.Bool("cache", false, "fetch from the module cache")
cacheDir = flag.String("cachedir", "", "module cache directory (defaults to `go env GOMODCACHE`)")
useProxy = flag.Bool("proxy", false, "fetch from GOPROXY if not found locally")
+ goRepoPath = flag.String("gorepo", "", "path to Go repo on local filesystem")
)
func main() {
@@ -107,6 +114,11 @@ func main() {
die("connecting to proxy: %s", err)
}
}
+
+ if *goRepoPath != "" {
+ stdlib.SetGoRepoPath(*goRepoPath)
+ }
+
server, err := newServer(ctx, paths, *gopathMode, downloadDir, prox)
if err != nil {
die("%s\nMaybe you need to provide the location of static assets with -static.", err)