How to Use go doc and godoc for Documentation

Cli
Use the go doc command to instantly view documentation for Go packages, symbols, and files directly in your terminal.

Use go doc to view documentation for packages, symbols, or files directly in your terminal. Run go doc followed by the import path or symbol name to retrieve the associated comments and usage information.

go doc net/http

For a specific function within a package, append the symbol name to the path:

go doc net/http.Get

To view documentation for a local file without importing it, pass the file path directly:

go doc ./my_package.go