How to use the go doc command line
Created
Doc prints the documentation comments associated with the item identified by its arguments (a package, const, func, type, var, method, or struct field) followed by a one-line summary of each of the first-level items "under" that item (package-level declarations for a package, methods for a type, etc.).
Show documentation for current package.
go doc
Show package docs for the doc command.
go doc cmd/doc
Show documentation for the encoding/json package.
go doc encoding/json
package json // import "encoding/json" Package json implements encoding and decoding of JSON as defined in RFC 7159. The mapping between JSON and Go values is described in the documentation for the Marshal and Unmarshal functions.
The go doc Commands and Options
Usage:
go <command> [arguments]
Flags:
-allShow all the documentation for the package.-cRespect case when matching symbols.-cmdTreat a command (package main) like a regular package. Otherwise package main's exported symbols are hidden when showing the package's top-level documentation.-shortOne-line representation for each symbol.-srcShow the full source code for the symbol. This will display the full Go source of its declaration and definition, such as a function definition (including the body), type declaration or enclosing const block. The output may therefore include unexported details.-uShow documentation for unexported as well as exported symbols, methods, and fields.