1

I know golang provides godoc to easily inspect go package (along with exported functions, function-level and package-level comments). It works fine for standard packages.

I tried to use it for my own package.

$ echo $GOPATH
/home/username/go

My package resides in /home/username/repo/proj/component.

Every time I tried to started a local server under /home/username/repo (which is where go.mod resides) by

godoc -http=localhost:8080  -goroot="../proj"

It always errors:

using module mode; GOMOD=/home/username/repo/go.mod
2022/05/15 14:38:43 cannot find package "." in:
        /src

I want to know what else should I do?

Tinyden
  • 524
  • 4
  • 13
  • The `-goroot` flag is used to specify where your go SDK is located, it should most likely not be your `../proj` directory, but the directory where you have Go installed. – Kevin B May 16 '22 at 07:49
  • @KevinB I have tried `godoc -http=localhost:8080 -goroot="/usr/local/go/bin"`, the go binary path is specified by `which go`. Still get the same issue. Do you know how to resolve it? – Tinyden May 16 '22 at 08:16
  • From what I can tell you are doing everything correctly besides perhaps the `-goroot`. When I do `good -http=localhost:8080` in one my my packages it works fine. It might be an issue with the layout of your project? Does the same occur if you do not specify the goroot at all? – Kevin B May 16 '22 at 08:47

0 Answers0