How to run godoc on some popular go repo?

huangapple go评论74阅读模式
英文:

How to run godoc on some popular go repo?

问题

新的godoc有一些很好的功能,比如调用者列表等。不过我在运行它时遇到了一些问题,比如:

➜  ~GOPATH git:(master) ✗ ls src/github.com/coreos/etcd/
CHANGELOG       DCO             Documentation   README.md       bench           build           contrib         error           fixtures        go_version.go   http            main.go         mod             scripts         store           tests
CONTRIBUTING.md Dockerfile      LICENSE         Vagrantfile     bin             config          discovery       etcd            foo             gopath          log             metrics         pkg             server          test.sh         third_party
➜  ~GOPATH git:(master) ✗ godoc github.com/coreos/etcd/discovery -http=:6060
No match found.

有人能告诉我如何在一些流行的Go仓库(如上面使用的etcd)上运行它吗?

英文:

New godoc have some nice features like list of callers etc. Anyway I have problems to run it, like:

➜  ~GOPATH git:(master) ✗ ls src/github.com/coreos/etcd/
CHANGELOG       DCO             Documentation   README.md       bench           build           contrib         error           fixtures        go_version.go   http            main.go         mod             scripts         store           tests
CONTRIBUTING.md Dockerfile      LICENSE         Vagrantfile     bin             config          discovery       etcd            foo             gopath          log             metrics         pkg             server          test.sh         third_party
➜  ~GOPATH git:(master) ✗ godoc github.com/coreos/etcd/discovery -http=:6060
No match found.

Does anyone can tell me how to run it on some popular go repos like etcd, which I am using above?

答案1

得分: 1

Godoc有两个主要功能:

  1. 它显示一个包的文档。
  2. 它运行一个Web服务器,你可以浏览以查看本地包的文档。

在这里,你正在尝试同时执行这两个功能。要么删除-http=:6060选项以在控制台中查看包的文档,要么删除包路径以运行Web服务器并在浏览器中搜索它。

英文:

Godoc have two main functionnalities:

  1. It displays the documentation for a package
  2. It run a webserver that you can browse to see you local packages documentation

Here, you are trying to do both at the same time. Either remove the -http=:6060 option to see the package documentation in the console, or remove the package path to run the webserver and search it in your browser.

答案2

得分: 0

Godoc可以在终端上运行代码文档以创建输出(不带-server或-http标志运行godoc),也可以作为带有-http/-server标签的服务器运行(不带其他参数)。不能同时两者兼顾。

如果您在包中看不到您的代码,则需要运行go install mypackage。例如,如果您克隆了github.com/coreos/etcd/discovery,则运行go install github.com/coreos/etcd/discovery,然后它应该出现在由godoc -http=:port运行的go文档页面中。

我在我的代码中遇到了这个问题,没有看到其他答案。

英文:

Godoc can either run documentation on your code to create output on the terminal (running godoc without -server or -http flags), or can be run as a server with -http/-server tags (and takes no other args). Can't be both at the same time.

If you don't see your code in packages, then you need to run go install mypackage For example if you have github.com/coreos/etcd/discovery cloned, then run go install github.com/coreos/etcd/discovery and it should appear in the go docs page run by godoc -http=:port

Just ran into this problem with my code and didn't see any other answers.

答案3

得分: 0

以下是要翻译的内容:

godoc -http=:6060 &
go get github.com/coreos/etcd/discovery
open http://localhost:6060/pkg/github.com/coreos/etcd/discovery

翻译结果:

godoc -http=:6060 &
go get github.com/coreos/etcd/discovery
打开 http://localhost:6060/pkg/github.com/coreos/etcd/discovery
英文:
godoc -http=:6060 &
go get github.com/coreos/etcd/discovery
open http://localhost:6060/pkg/github.com/coreos/etcd/discovery

huangapple
  • 本文由 发表于 2014年6月26日 00:04:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/24413562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定