英文:
offline document for go/golang
问题
有没有可以安装的Ubuntu离线文档包,这样我就可以离线阅读Go的包文档了?
我以为是golang-doc
,但实际上不是这样的——里面没有任何Go包的文档。
然后我进一步研究并尝试了以下命令:
godoc -http=:6060
但是访问http://127.0.0.1:6060/pkg/给我返回了以下错误:
lstat /usr/lib/go/doc: no such file or directory
如何离线阅读Go包的文档?
PS. 我的Ubuntu和golang-go包信息:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.04
Release: 15.04
Codename: vivid
$ apt-cache policy golang-go
golang-go:
Installed: 2:1.4.2
Candidate: 2:1.4.2
Version table:
*** 2:1.4.2 0
500 http://ppa.launchpad.net/evarlast/golang1.4/ubuntu/ vivid/main amd64
英文:
Is there any Ubuntu go offline document package that I can install so that I can read the package docs for Go offline?
I thought it would be golang-doc
but it is actually not -- there aren't any Go package docs in it.
Then I research further and tried
godoc -http=:6060
but visiting http://127.0.0.1:6060/pkg/ gives me
lstat /usr/lib/go/doc: no such file or directory
How to read the Go package docs offline?
PS. My Ubuntu and golang-go package:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.04
Release: 15.04
Codename: vivid
$ apt-cache policy golang-go
golang-go:
Installed: 2:1.4.2
Candidate: 2:1.4.2
Version table:
*** 2:1.4.2 0
500 http://ppa.launchpad.net/evarlast/golang1.4/ubuntu/ vivid/main amd64
答案1
得分: 21
我不确定标记为正确答案的答案是否真的是正确答案 - 至少我无法使用它离线访问golang文档。
在Mac上,这对我有效。我没有在Ubuntu上测试过。
如果你已经安装了godoc,请运行以下命令:
godoc -http=:6060
然后使用以下URL在浏览器中打开:
http://127.0.0.1:6060/pkg/
或者http://127.0.0.1:6060/以查看golang网站的第一页。
然后,你就可以访问golang网站上的所有文档了。
英文:
I am not sure the answer marked as correct is actually the correct answer - I could not access the golang documentation offline using that at least.
This works for me on a Mac. I have not tested it on Ubuntu.
If you have godoc installed, run the following command:
godoc -http=:6060
Then open a browser with the following URL:
http://127.0.0.1:6060/pkg/
Or http://127.0.0.1:6060/ to see the first page of the golang web site.
All of the doco from the gloang web site will then be available to you.
答案2
得分: 13
根据从源代码安装Go的说明:
几个Go工具(包括godoc)的源代码保存在go.tools仓库中。要安装所有这些工具,请运行go get命令:
$ go install golang.org/x/tools/cmd/...@latest
或者如果你只想安装特定的命令(在这种情况下是godoc):
$ go install golang.org/x/tools/cmd/godoc@latest
要安装这些工具,go get命令要求本地安装Git。
你还必须设置一个工作空间(GOPATH);详细信息请参见如何编写Go代码。
注意:go命令将godoc二进制文件安装到$GOROOT/bin(或$GOBIN),将cover和vet二进制文件安装到$GOROOT/pkg/tool/$GOOS_$GOARCH。你可以使用"go tool cover"和"go tool vet"访问后者命令。
根据这些信息,你是否尝试过:
- 使用
$ go install golang.org/x/tools/cmd/godoc@latest
安装godoc
- 使用
$ git --version
验证Git是否已安装 - 使用
$ echo $GOPATH
验证GOPATH是否已设置
英文:
According to Installing Go from source:
> The source code for several Go tools (including godoc) is kept in the go.tools repository. To install all of them, run the go get command:
>
> $ go install golang.org/x/tools/cmd/...@latest
>
> Or if you just want to install a specific command (godoc in this case):
>
> $ go install golang.org/x/tools/cmd/godoc@latest
>
> To install these tools, the go get command requires that Git be installed locally.
>
> You must also have a workspace (GOPATH) set up; see How to Write Go Code for the details.
>
> Note: The go command will install the godoc binary to $GOROOT/bin (or $GOBIN) and the cover and vet binaries to $GOROOT/pkg/tool/$GOOS_$GOARCH. You can access the latter commands with "go tool cover" and "go tool vet".
Based on that information, have you tried:
- Installing
godoc
using$ go install golang.org/x/tools/cmd/godoc@latest
- Verifying Git is installed using
$ git --version
- Verifying the GOPATH using
$ echo $GOPATH
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论