如何从任何文件夹生成文档?

I have a package with files called test which is in the folder ~/my_packages/test.

My GoPath is set to ~/go, i.e

$ echo $GOPATH
~/go

What arguments need to be passed to godoc in to view the documentation of files for the test package?

I have tried:

  • godoc -goroot=~/my_packages test
    • Result: cannot find package "." in: /src/test
  • godoc -goroot=~/my_packages ./test
    • Result: cannot find package "." in: /target
  • export GOPATH=$GOPATH:~/my_packages; godoc test
    • Result: cannot find package "." in: /src/test

I can start the godoc HTTP server and see the folder, but only the code is visible. The expected package documentation is not available.

godoc -http=:6060 -goroot=/full/path/to/my_packages

What godoc command can be run to generate documentation for packages in folders in any directory?

Thank you in advance for your help!