pymd
pymd

Reputation: 4401

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

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

Upvotes: 47

Views: 40895

Answers (11)

Sergey
Sergey

Reputation: 71

I've installed go and also havn't godoc, but I see: go doc fmt

(go doc - I see from go help)

Upvotes: 0

Roney Thomas
Roney Thomas

Reputation: 1563

Install godoc by using go install

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

Upvotes: 86

Sabuhi Shukurov
Sabuhi Shukurov

Reputation: 1918

For Fedora:

sudo dnf install golang-godoc

godoc -http=localhost:8080

Upvotes: 0

Thomas Bratt
Thomas Bratt

Reputation: 51912

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

Upvotes: 13

Aditya Hajare
Aditya Hajare

Reputation: 1391

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
    

Upvotes: 18

Alex Fortuna
Alex Fortuna

Reputation: 1243

This worked for me (I prefer to install Go by hand in /usr/local/go):

$ sudo -i
root# unset GOPATH
root# go get golang.org/x/tools/cmd/godoc
root# which godoc
/usr/local/go/bin/godoc

Cheers!

Upvotes: 1

Xiaorong Liao
Xiaorong Liao

Reputation: 1267

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.gz
tar -xvf go1.6.linux-amd64.tar.gz
mv go /usr/local

The 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/bin
go version

godoc should be usable now.

Upvotes: 1

prashant.dhuri
prashant.dhuri

Reputation: 31

You can use sudo apt install golang-golang-x-tools to install go doc on ubuntu.

Upvotes: 3

Dariush Abbasi
Dariush Abbasi

Reputation: 470

in ubuntu 14.04 have to install golang,golang-doc and golang-go.tools :

sudo apt-get update
sudo apt-get install golang
sudo apt-get install golang-doc
sudo apt-get install golang-go.tools

and for use, run :

godoc -http=:6060 

and open localhost:6060 in your browser.

Upvotes: 3

Stephen Weinberg
Stephen Weinberg

Reputation: 53448

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.

Upvotes: 25

Louis Thibault
Louis Thibault

Reputation: 21450

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

sudo apt-get install golang-go.tools

Upvotes: 9

Related Questions