Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

godoc command not found

godoc command doesn't work on my system (I'using Linux Mint 20 Ulyana).

I've just tried this procedure:

  1. install godoc with following command:

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

  1. Start godoc server:

godoc -http=:6060

The result is: bash: godoc: command not found

I'm using this go version go version go1.15 linux/amd64

And this is my PATH variable /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin

All other go commands (go build, go run and so on) work correctly.

What can I do to make godoc command work?

like image 288
Alberto Morreale Avatar asked Aug 16 '20 22:08

Alberto Morreale


People also ask

How to install godoc in Golang?

install godoc with following command: go get golang.org/x/tools/cmd/godoc. Start godoc server: godoc -http=:6060. The result is: bash: godoc: command not found. I'm using this go version go version go1.15 linux/amd64. ...

Where can I find the source code for godoc?

The source code for GoDoc is available on GitHub. GoDoc displays documentation for GOOS=linux unless otherwise noted at the bottom of the documentation page. If you want to lookup some package’s documents in command line, you should install the go tool at first.

What is godoc in Python?

Godoc is conceptually related to Python’s Docstring and Java’s Javadoc but its design is simpler. The comments read by godoc are not language constructs (as with Docstring) nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments, the sort you would want to read even if godoc didn’t exist.

Are godoc comments machine-readable?

The comments read by godoc are not language constructs (as with Docstring) nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments, the sort you would want to read even if godoc didn’t exist.


1 Answers

Step - 1: Check if godoc package is installed

Make sure you can run godoc using this command:

$GOPATH/bin/godoc -http=:6060

Step - 2: Install godoc package

If you don't see any error then go to Step - 4 else if you can see this error No such file or directory then you have to get the godoc package first by using this command:

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

It will take some time to install.

Step - 3: Try godoc command

Try this command

godoc --help

if this command ran successfully then you are done and nothing else to do else if you are still getting any errors follow the Step - 4 and if you still fail please check if you have defined the $GOPATH variable correctly

Step - 4: Add path variable

Add $GOPATH/bin to your PATH variable by using this command:

export PATH="$GOPATH/bin:$PATH"

Try Step - 3 now.

like image 76
princebillyGK Avatar answered Oct 11 '22 22:10

princebillyGK