go-doc
Display Go package documentation
TLDR
View documentation for the current package
Show package documentation and exported symbols
Show also documentation of symbols
Show also sources
Show a specific symbol
SYNOPSIS
go doc [flags] [package] [name …]
PARAMETERS
-u
Show documentation for unexported (private) names too.
-c
Respect case when matching selector lists (show all methods matching the selector, even if casing doesn't match exactly).
-help
Print usage information.
DESCRIPTION
The go doc command is part of the Go programming language toolchain and provides a quick way to view documentation for Go packages, types, functions, and other symbols directly from the command line.
It reads Go source code and extracts structured documentation comments (godoc-style) to display usage information, making it ideal for developers working in terminals without needing a web browser.
For example, running go doc fmt shows the documentation for the fmt package, while go doc fmt.Print displays details for the specific Print function. It supports recursive lookup across imported packages and can include unexported (private) names with the -u flag.
This tool promotes efficient code exploration and is lightweight compared to full documentation servers like the deprecated godoc. It's commonly used during development for instant reference.
CAVEATS
Requires Go toolchain installed; does not render HTML or advanced formatting; limited to source code comments.
EXAMPLES
go doc fmt
Shows fmt package overview.
go doc -u fmt Print
Displays Print function docs including unexported details.
go doc sync.Mutex
Views sync.Mutex type documentation.
EXIT STATUS
0 on success, non-zero on error (e.g., package not found).
HISTORY
Introduced in Go 1.0 (2009) as part of the integrated go tool. Evolved with Go releases; godoc server deprecated in Go 1.13 in favor of pkg.go.dev, but go doc remains a core CLI tool.


