offline document for go/golang

Issue

Is there any Ubuntu go offline document package that I can install so that I can read the package docs for Go offline?

I thought it would be golang-doc but it is actually not — there aren’t any Go package docs in it.

Then I research further and tried

godoc -http=:6060

but visiting http://127.0.0.1:6060/pkg/ gives me

lstat /usr/lib/go/doc: no such file or directory

How to read the Go package docs offline?

PS. My Ubuntu and golang-go package:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:        15.04
Codename:       vivid

$ apt-cache policy golang-go
golang-go:
  Installed: 2:1.4.2
  Candidate: 2:1.4.2
  Version table:
 *** 2:1.4.2 0
        500 http://ppa.launchpad.net/evarlast/golang1.4/ubuntu/ vivid/main amd64

Solution

According to Installing Go from source:

The source code for several Go tools (including godoc) is kept in the go.tools repository. To install all of them, run the go get command:

$ go install golang.org/x/tools/cmd/...@latest

Or if you just want to install a specific command (godoc in this case):

$ go install golang.org/x/tools/cmd/godoc@latest

To install these tools, the go get command requires that Git be installed locally.

You must also have a workspace (GOPATH) set up; see How to Write Go Code for the details.

Note: The go command will install the godoc binary to $GOROOT/bin (or $GOBIN) and the cover and vet binaries to $GOROOT/pkg/tool/$GOOS_$GOARCH. You can access the latter commands with "go tool cover" and "go tool vet".

Based on that information, have you tried:

  1. Installing godoc using $ go install golang.org/x/tools/cmd/godoc@latest
  2. Verifying Git is installed using $ git --version
  3. Verifying the GOPATH using $ echo $GOPATH

Answered By – Matthew Rankin

Answer Checked By – Candace Johnson (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.