Pkgsite extracts and generates documentation for Go programs. It runs as a web server and presents the documentation as a web page.
To install, run `go install golang.org/x/pkgsite/cmd/pkgsite@latest`.
With no arguments, pkgsite will serve docs for main modules relative to the current directory, i.e. the modules listed by `go list -m`. This is typically the module defined by the nearest go.mod file in a parent directory. However, this may include multiple main modules when using a go.work file to define a workspace.
For example, both of the following forms could be used to work on the module defined in repos/cue/go.mod:
The single module form:
cd repos/cue && pkgsite
The multiple module form:
go work init repos/cue repos/other && pkgsite
By default, the resulting server will also serve all of the module's dependencies at their required versions. You can disable serving the required modules by passing -list=false.
You can also serve docs from your module cache, directly from the proxy (it uses the GOPROXY environment variable), or both:
pkgsite -cache -proxy
With either -cache or -proxy, pkgsite won't look for a module in the current directory. You can still provide modules on the local filesystem by listing their paths:
pkgsite -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), you can provide its location with the -gorepo flag to save a little time.