A suite of tools for exploring Go API documentation.
It ships with:
- godoc-cli β β¨ a richly rendered terminal viewer for Go docs.
- godoc-mcp β π€ an MCP server that lets AI tooling fetch Go docs on demand.
go.dw1.io/godocβ π¦ the library powering both binaries, so you can embed doc loading in your own apps.
Note
Requires Go 1.25 or newer.
Install the godoc CLI and godoc MCP from source:
go install go.dw1.io/godoc/cmd/godoc-{cli,mcp}@latestThe binaries will be placed in $GOBIN (or $GOPATH/bin if unset).
For library, see library section.
godoc-cli renders Go documentation with Glamour for syntax-aware Markdown output. It understands modules, respects GOOS/GOARCH, and can emit JSON when you need structured data.
The binary is called
godoc-clito sidestep naming clashes with thegolang.org/x/tools/cmd/godoctool.
godoc-cli [options]
godoc-cli [options] <pkg>
godoc-cli [options] <sym>[.<methodOrField>]
godoc-cli [options] [<pkg>.]<sym>[.<methodOrField>]
godoc-cli [options] [<pkg>.][<sym>.]<methodOrField>
godoc-cli [options] <pkg> <sym>[.<methodOrField>]
Options
| Flag | Description |
|---|---|
-goos string |
Target operating system (linux, darwin, windows, β¦). |
-goarch string |
Target architecture (amd64, arm64, β¦). |
-workdir string |
Working directory for resolving relative import paths (default: current dir). |
-version string |
Module version to fetch (e.g., v1.2.3, latest). |
-style string |
Glamour theme: auto (default), dark, light, notty. |
-pager |
Render output inside an interactive pager UI (press ? for controls, c to copy). |
-json |
Emit raw JSON instead of rendered Markdown. |
-help |
Print the usage guide. |
godoc detects terminal width and theme when -style=auto. When stdout isnβt a TTY (e.g., piping to a file), it falls back to a minimal renderer so you can feed the output into other tools.
Tip
- Use
-style=nottyin environments without ANSI color support. - Use
-pagerto explore large packages.- With
-pager, press?to toggle inline help orcto copy the document to your clipboard.
- With
- The CLI shares caches and configuration with the library, so Go toolchain settings (
GOPROXY,GOCACHE, etc.) apply automatically.
Use these commands to explore docs quickly.
Docs for the current module
godoc-cliRemote package browsing
godoc-cli github.com/gorilla/muxSymbol lookup
godoc-cli net/http Request.ParseForm
godoc-cli fmt.Println
godoc-cli net/http.StatusOKVersion pinning
godoc-cli -version v1.8.0 github.com/gorilla/muxJSON output
godoc-cli -json fmt.Printf | jqInteractive pager
godoc-cli -pager net/http RequestPlatform-specific APIs
godoc-cli -goos windows -goarch arm64 runtimegodoc-mcp wraps the same engine in an MCP server so assistants like Claude Desktop, Cursor, or any other AI apps can serve Go docs inside a conversation.
Launches an MCP server over STDIO:
godoc-mcpThe server registers one tool: load.
| Argument | Type | Required | Description |
|---|---|---|---|
import_path |
string | β | Go import path (fmt, net/http, github.com/user/repo, .). |
selector |
string | β | Symbol selector (Printf, Request.ParseForm, StatusOK, β¦). Empty loads the full package. |
version |
string | β | Module version (v1.2.3, latest). Empty uses the default/installed version. |
goos |
string | β | Target OS for cross-compilation (linux, darwin, windows, β¦). |
goarch |
string | β | Target architecture (amd64, arm64, β¦). |
workdir |
string | β | Directory used to resolve relative import paths (defaults to the hostβs current working directory). |
Calls return the raw godoc.Result (either PackageDoc or SymbolDoc) plus the request metadata (import_path, selector, version). See the library section below for schema details.
{
"mcpServers": {
"memory": {
"command": "/path/to/go/bin/godoc-mcp"
}
}
}After saving, restart your MCP host.
The library powers both binaries and is available for embedding in servers, CLIs, or automation. It can load package docs, symbols, and methods from local modules or remote sources, with optional version pinning and cross-compilation.
go get go.dw1.io/godocpackage main
import (
"context"
"fmt"
"time"
"go.dw1.io/godoc"
)
func main() {
g := godoc.New(
godoc.WithGOOS("linux"),
godoc.WithGOARCH("amd64"),
godoc.WithContext(context.Background()),
)
result, err := g.Load("fmt", "Printf", "")
if err != nil {
panic(err)
}
fmt.Println(result.Text())
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
defer cancel()
g = godoc.New(godoc.WithContext(ctx))
_, _ = g.Load("github.com/gorilla/mux", "", "latest")
}Load(importPath, sel, version string) (Result, error)importPath: package import path (e.g.,fmt,net/http,github.com/user/repo,.)sel: symbol selector (Printf,Request.ParseForm, β¦); leave empty for the whole packageversion: module version (v1.2.3,latest); leave empty for the default version
The returned Result implements Text(), HTML(), and MarshalJSON().
type PackageDoc struct {
ImportPath string `json:"import_path"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
DocText string `json:"doc"`
Consts []ValueDoc `json:"consts"`
Vars []ValueDoc `json:"vars"`
Funcs []FuncDoc `json:"funcs"`
Types []TypeDoc `json:"types"`
}
type SymbolDoc struct {
ImportPath string `json:"import_path"`
Package string `json:"package"`
Kind string `json:"kind"`
Name string `json:"name"`
Receiver string `json:"receiver"`
Args []ArgInfo `json:"args"`
DocText string `json:"doc"`
}Use the higher-level convenience methods or marshal to JSON to feed docs into other systems.
Caution
godoc has NOT reached 1.0 yet. Therefore, this library does not offer a stable API; use at your own risk.
There are no guarantees of stability for the APIs in this library.
Go ahead.
The entire project (CLI, MCP server, and library) is licensed under the MIT License. See LICENSE.