Installing godoc for golang (go 1.2)

This article was published 5 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

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

Thoughts on this post

kaskavalci 2016-01-06

Thanks Mıchael. However go get returns with warning;
warning: is shutting down; import path will stop working
the command has moved; use instead.

You should use `go get`

michael 2016-01-08

Thanks Halil, the post has been updated :)

Leave a comment?