Accessing Go Documentation

Let’s learn about the go doc and godoc utilities.

The go doc and godoc utilities

The Go distribution comes with a plethora of tools that can make our lives as programmers easier. Two of these tools are the go doc subcommand and the godoc utility, which allow us to see the documentation of existing Go functions and packages without needing an internet connection. We can also view the Go documentation online. Because godoc is not installed by default, we might need to install it by running go get golang.org/x/tools/cmd/godoc.

The go doc command can be executed as a normal command-line application that displays its output on a terminal, and godoc can be executed as a command-line application that starts a web server. In the latter case, we need a web browser to look at the Go documentation. The first utility is similar to the UNIX man(1) command but for Go functions and packages.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy