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

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

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?

Leave a Reply