The Go distribution comes with a plethora of tools that can make your life as a programmer easier. One of these tools is the godoc utility, which allows you to see the documentation of existing Go functions and packages without needing an internet connection.
The godoc utility can be executed either as a normal command-line application that displays its output on a terminal, or as a command-line application that starts a web server. In the latter case, you will need a web browser to look at the Go documentation.
If you type godoc without any command-line parameters, you will get a list of the command-line options supported by godoc.
The first way is similar to using the man(1) command, but for Go functions and packages. So, in order to find information about the Printf() function of the fmt package, you should execute the following command:
$ go doc fmt.Printf
Similarly, you can find information about the entire fmt package by running the following command:
$ go doc fmt
The second way requires executing godoc with the -http parameter:
$ godoc -http=:8001
The numeric value in the preceding command, which in this case is 8001, is the port number the HTTP server will listen to. You can choose any port number that is available provided that you have the right privileges. However, note that port numbers 0-1023 are restricted and can only be used by the root user, so it is better to avoid choosing one of those and pick something else, provided that it is not already in use by a different process.
You can omit the equal sign in the presented command and put a space character in its place. So, the following command is completely equivalent to the previous one:
$ godoc -http :8001
After that, you should point your web browser to the http://localhost:8001/pkg/ URL in order to get the list of available Go packages and browse their documentation.