Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

offline document for go/golang

Tags:

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 
like image 868
xpt Avatar asked Aug 15 '15 02:08

xpt


2 Answers

I am not sure the answer marked as correct is actually the correct answer - I could not access the golang documentation offline using that at least.

This works for me on a Mac. I have not tested it on Ubuntu.

If you have godoc installed, run the following command:

godoc -http=:6060 

Then open a browser with the following URL: http://127.0.0.1:6060/pkg/

Or http://127.0.0.1:6060/ to see the first page of the golang web site.

All of the doco from the gloang web site will then be available to you.

like image 101
Bryon Avatar answered Sep 24 '22 08:09

Bryon


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 get golang.org/x/tools/cmd/...

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

$ go get golang.org/x/tools/cmd/godoc

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 get golang.org/x/tools/cmd/godoc
  2. Verifying Git is installed using $ git --version
  3. Verifying the GOPATH using $ echo $GOPATH
like image 23
Matthew Rankin Avatar answered Sep 24 '22 08:09

Matthew Rankin