英文:
How to run pkg.go.dev locally as a godoc replacement?
问题
godoc
已经从Go标准安装中移除自1.12版本,而且看起来它不会很快得到更新。pkg.go.dev
至少看起来是它的继任者。它还具有其他文档功能,比如获取README.md
文件并在文档页面中呈现。
出于这些原因,我希望切换到在本地使用pkg.go.dev
来查看和创建小型内部包的文档。主要问题是,与godoc
不同,似乎没有明确的使用指南。我也不知道pkg.go.dev
是否完全适合这个任务。所以我想知道:
- 是否可以并且应该将
pkg.go.dev
用作本地的godoc
替代品? - 如果是,我应该如何运行它来完成这个任务?
英文:
godoc
has been removed from the go standard install since 1.12 and looks like it wont be updated anytime soon. pkg.go.dev
at least appears to be its successor. It also has additional documentation features like grabbing the README.md
file and rendering it in the documentation page.
For these reasons I was hoping to switch over to using pkg.go.dev
locally to view and create documentation for small internal packages. The major issue is that unlike godoc
there does not seem to be a clear usage guide. I also do not know if pkpg.go.dev
is completely overkill for this task. So I would like to know:
- Can and should
pkg.go.dev
be used as a localgodoc
replacement? - If yes, how would I run it for this task?
答案1
得分: 2
运行本地 pkgsite。
go install golang.org/x/pkgsite/cmd/pkgsite@latest && pkgsite
参考资料:
英文:
Run pkgsite locally.
go install golang.org/x/pkgsite/cmd/pkgsite@latest && pkgsite
References:
答案2
得分: 0
你可以使用x/tools/godoc来使用之前的godoc工具。
英文:
You can use the x/tools/godoc that has the previous godoc tool
答案3
得分: 0
运行godoc
1本身对我来说是可行的,但是非常慢,因为它会为标准库中的每个包生成文档,而我只关心我正在使用的本地包。为此,如果您的包在名为something
的文件夹中,您可以将该文件夹移动,使其看起来像这样:
godoc/src/something
然后,进入godoc
文件夹,运行
godoc -goroot .
然后,浏览到localhost:6060
。或者,还有另一个用于Go文档的网站 2。
英文:
Running godoc
1 on its own worked for me, but was really slow because it generates docs for every single package in the standard library, while I only care about the local package that I am working on. To that end, if your package is in a folder called something
, you can move the folder so that it looks like this:
godoc/src/something
Then, go to the godoc
folder, and run
godoc -goroot .
Then, browse to localhost:6060
. Alternatively, another site is available for
Go docs 2.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论