Godoc local package

(Luca Paterlini) #1

I am trying without success to generate the documentation of a local package I have created and then access it.

Tk in advance,

(Lutz Horn) #2

Which exact commands do you execute? What happens?

(Luca Paterlini) #3

I execute godoc src/calc

godoc src/calc
2019/02/12 11:20:17 cannot find package “.” in:

this is my gopath

echo $GOPATH

this is the path where the package is


(Norbert Melzer) #4

If your $GOPATH is /foo and you have some package in /foo/src/bar, than the package name is only bar. Please try godoc calc.

(Luca Paterlini) #5

same result, godoc calc
2019/02/12 12:20:30 cannot find package “.” in:

I went a bit better with this command but no trace of the example file

/Documents/go_study/ goRecipes/src/testing/testing8_1/src/calc$ godoc .

package calc
import “.”

Package calc implements sum and avg


func Average(nums …int) float64

func Sum(nums …int) int

(Norbert Melzer) #6

Are you sure your GOPATH is /home/pater92/Documents/go_study/goRecipes/src/testing/testing8_1/? From the very same terminal where you call godoc please invoke go env GOPATH

(Luca Paterlini) #7

Yes, better I have changed the gopath there was a black character in the go path

pater92@pater92-HP-Notebook:~/Documents/go_study/goRecipes/src/testing/testing8_1$ go doc calc
package calc // import “calc”

Package calc implements sum and avg

func Average(nums …int) float64
func Sum(nums …int) int
pater92@pater92-HP-Notebook:~/Documents/go_study/goRecipes/src/testing/testing8_1$ go doc calc -http=:3000
doc: invalid identifier “-http=:3000”
exit status 1

In the first command no traces of the example files , the second command just errors and its a my target run the server of godoc for that specific package only. Tk in advance for any further assistance

(Norbert Melzer) #8

Swap the arguments, the package has to be the last.