How to use godoc for self-defined packages

247 Views Asked by At

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?

0

There are 0 best solutions below