go doc
The go subcommand that prints the documentation for a package, function or type from the toolchain you have installed.
In more detail
Documentation in Go is written as comments above each declaration, and go doc reads it back to you in the terminal. Because it reads your installed version, the answer always matches the code you are building against. The first lines show the package and the function signature.
Examples
go doc fmt.Printlngo doc os.GetenvRelated terms
- go command — The single command-line program that ships with Go and builds, runs, tests, formats and documents your code through subcommands.
- function signature — The name, parameters and their order that define how a function must be called.
Taught in
- Installing the Go Toolchain — Concurrent Systems Programming with Go