godoc
Display Go documentation and source code
TLDR
Display help for a specific package
Display help for the function "Printf" of "fmt" package
Serve documentation as a web server on port 6060
Create an index file
Use the given index file to search the docs
SYNOPSIS
godoc [options] [pkgpath...]
PARAMETERS
-http=addr
HTTP service address (default localhost:6060)
-path=dirlist
Directories to search for Go packages
-play
Enable embedded Go playground
-src
Include source code in output
-index
Rebuild search index (includes file contents)
-api
Show only API declarations
-html
Print HTML instead of plain text
-json
Print JSON output
-output=dir
Write static docs to directory
-v
Verbose mode
-analysis=object
Analysis passes (default type)
-links
Print hyperlinks to packages/URLs
-maxhistory=N
Max changes shown (default 10)
DESCRIPTION
Godoc is a documentation tool for the Go programming language, part of the Go toolchain. It extracts special godoc comments from Go source code and generates human-readable documentation, typically served as HTML pages over HTTP or output as plain text/HTML/JSON.
By default, running godoc without arguments starts an HTTP server at localhost:6060, allowing browsing of installed Go packages via a web interface. Users can specify package paths (e.g., godoc fmt) to view docs for specific packages, with options to show source code (-src), enable interactive playground (-play), or generate static output.
It indexes package contents for search and supports custom templates. Godoc is widely used for local documentation of Go projects and standard library exploration. However, it is deprecated since Go 1.19 in favor of online services like pkg.go.dev and the go doc command for terminal use.
CAVEATS
Deprecated since Go 1.19 (2022); prefer go doc or pkg.go.dev.
Requires Go installed; no longer built by default in recent Go versions.
Index rebuild (-index) can be slow on large GOPATHs.
EXAMPLES
godoc -http=:6060 &
Start server (background), visit http://localhost:6060.
godoc -src fmt
Show fmt package docs with source.
godoc -play io/ioutil
View ioutil with playground.
EXIT STATUS
0 on success, 1 on error (e.g., invalid package, server bind fail).
HISTORY
Introduced in Go 1.0 (2012) by Go team for auto-generating docs from comments. Evolved with features like playground (Go 1.5+). Deprecated in Go 1.19 as pkg.go.dev provides superior online hosting and search.


