How to make "godoc" command work on my system?

26,181

Solution 1

The following worked for me on Ubuntu 13.10:

sudo apt-get install golang-doc
godoc -http=:6060

Navigate to http://localhost:6060


EDIT: The version shipped with the distribution is likely to be out of date. I'm not an active Go user at the moment but this answer looks the most complete: https://stackoverflow.com/a/61300854/15985

Solution 2

Install godoc by using go install

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

Solution 3

As has been pointed out by others some changes in Go 1.2 have caused the debian package maintainers to make some changes. The current way to install godoc is

sudo apt-get install golang-go.tools

This is because the Go developers moved godoc out of the normal distribution and into the go.tools subrepo. This subrepo is updated more frequently and has different rules for backwards compatibility.



Old answer:

It looks like you installed from the ubuntu package. You need to install golang-doc package in order to use godoc. This is installed automatically if you install the golang metapackage.

sudo apt-get install golang

If you use packages to install Go, I also recommend installing from the gophers PPA. Current packages are very old. The current is 1.0.2 when 1.0.3 was the final 1.0 release and 1.1 is the current version number. Details can be found at https://wiki.ubuntu.com/Go.

Solution 4

Simplest way:

  1. First, install godoc with following command:

    go get golang.org/x/tools/cmd/godoc
    
  2. Start godoc server:

    godoc -http=:6060
    
  3. In your browser, visit:

    http://localhost:6060
    

Solution 5

You need to install the golang-go.tools package.

sudo apt-get install golang-go.tools

Share:
26,181
pymd
Author by

pymd

Updated on July 10, 2022

Comments

  • pymd
    pymd almost 2 years

    "godoc" doesnt' work on my system.(I'm using ubuntu 13.04)

    godoc fmt
    

    gives the following error

    2013/06/08 19:12:43 readTemplate: open /usr/lib/go/lib/godoc/codewalk.html: no such file or directory
    

    "which go" gives:

    /usr/bin/go
    

    "go env" gives the following:

    GOROOT="/usr/lib/go"
    GOBIN=""
    GOARCH="386"
    GOCHAR="8"
    GOOS="linux"
    GOEXE=""
    GOHOSTARCH="386"
    GOHOSTOS="linux"
    GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
    GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
    CGO_ENABLED="1"
    

    What should I do to make it work?