"godoc" doesnt' work on my system.(I'm using ubuntu 13.04)
godoc fmtgives 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?
Best Answer
Install godoc by using go install
go install -v golang.org/x/tools/cmd/godoc@latestAs 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.toolsThis 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 golangIf 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.
Simplest way:
First, install
godocwith following command:go get golang.org/x/tools/cmd/godocStart
godocserver:godoc -http=:6060In your browser, visit:
http://localhost:6060
The following worked for me on Ubuntu 13.10:
sudo apt-get install golang-docgodoc -http=:6060Navigate 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
You need to install the golang-go.tools package.
sudo apt-get install golang-go.tools
in ubuntu 14.04 have to install golang,golang-doc and golang-go.tools :
sudo apt-get updatesudo apt-get install golangsudo apt-get install golang-docsudo apt-get install golang-go.toolsand for use, run :
godoc -http=:6060 and open localhost:6060 in your browser.
You can use sudo apt install golang-golang-x-tools to install go doc on ubuntu.
First uninstall golang
apt-get purge golang*Download compiled go archive from https://golang.org/dl/
wget https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gztar -xvf go1.6.linux-amd64.tar.gzmv go /usr/localThe mving is not really necessary, though. You could just create a symlink /usr/local/go pointing to your go installation directory.
sudo ln -s $GO_HOME /usr/local/go
You may need to set Go Paths. Then you can test your install.
export PATH=$PATH:/usr/local/go/bingo versiongodoc should be usable now.
This worked for me (I prefer to install Go by hand in /usr/local/go):
$ sudo -iroot# unset GOPATHroot# go get golang.org/x/tools/cmd/godocroot# which godoc/usr/local/go/bin/godocCheers!
For Fedora:
sudo dnf install golang-godoc
godoc -http=localhost:8080
I've installed go and also havn't godoc, but I see:go doc fmt
(go doc - I see from go help)