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

Posted on Mar 24, 2023

Question

"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?

Answer

Install godoc by using go install

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