bd17c084df
This change replaces the env package with a new golangorgenv package. The previous env package existed primarily to configure the godoc instance that was running golang.org. By now, the golang.org website has been factored out to x/website, which has its own env package, but ends up still using this env package indirectly via x/tools/godoc. The goal of this change is to make env available for other services that run on subdomains of golang.org, so they can continue to safely rely on the x/tools/playground, which will be modified in the next commit to also use the new golangorgenv. The golangorgenv package replaces the IsProd function with a more specific one. Start using it in packages x/tools/{,cmd}/godoc. Also, re-arrange the order of checks to give the host suffix check higher priority than the environment variable check. This way, if the environment variable isn't set, the host suffix check gets a chance to run. When getting the value of "X-AppEngine-Country" header, use its canonical format "X-Appengine-Country" to avoid an allocation. This does not change behavior. Updates golang/go#30486 Change-Id: I97b47211a45ca0351f31fcb4fa6d408a4b0c4c7c Reviewed-on: https://go-review.googlesource.com/c/tools/+/165459 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> |
||
---|---|---|
.. | ||
analysis | ||
golangorgenv | ||
redirect | ||
static | ||
util | ||
vfs | ||
corpus.go | ||
dirtrees_test.go | ||
dirtrees.go | ||
format.go | ||
godoc17_test.go | ||
godoc_test.go | ||
godoc.go | ||
index_test.go | ||
index.go | ||
linkify.go | ||
meta.go | ||
page.go | ||
parser.go | ||
pres.go | ||
README.md | ||
search.go | ||
server_test.go | ||
server.go | ||
snippet.go | ||
spec_test.go | ||
spec.go | ||
spot.go | ||
tab.go | ||
template.go | ||
versions_test.go | ||
versions.go |
godoc
This directory contains most of the code for running a godoc server. The executable lives at golang.org/x/tools/cmd/godoc.
Development mode
In production, CSS/JS/template assets need to be compiled into the godoc binary. It can be tedious to recompile assets every time, but you can pass a flag to load CSS/JS/templates from disk every time a page loads:
godoc -templates=$GOPATH/src/golang.org/x/tools/godoc/static -http=:6060
Recompiling static assets
The files that live at static/style.css
, static/jquery.js
and so on are not
present in the final binary. They are placed into static/static.go
by running
go generate
. So to compile a change and test it in your browser:
-
Make changes to e.g.
static/style.css
. -
Run
go generate golang.org/x/tools/godoc/static
sostatic/static.go
picks up the change. -
Run
go install golang.org/x/tools/cmd/godoc
so the compiledgodoc
binary picks up the change. -
Run
godoc -http=:6060
and view your changes in the browser. You may need to disable your browser's cache to avoid reloading a stale file.