Installing godoc for golang (go 1.2)

I recently read about godoc, but when I went to try it the binary wasn’t installed.

Fortunately, it was a relatively easy fix:

go get

As it wants to write to a privileged location (/usr/lib/go/bin/), you might need to run it as root

sudo -E go get

The -E flag means “preserve environment variables”, which you’ll need to preserve your $GOPATH.

Next, add /usr/lib/go/bin/ to your path:

export PATH=/usr/lib/go/bin/:$PATH

Then run godoc:

$ godoc fmt Println
func Println(a ...interface{}) (n int, err error)
    Println formats using the default formats for its operands and writes to
    standard output. Spaces are always added between operands and a newline
    is appended. It returns the number of bytes written and any write error

June 11, 2014

How To