本文介绍了为什么在运行`go get golang.org / x / tools / cmd / godoc`时没有创建二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
godoc 和 gotour 可以通过去从其respecitve源目录中运行构建。当一个 go得到时创建的 gotour 二元的原因是什么,而 godoc 。命令行输出:
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> ls
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> go env
GOARCH =amd64
GOBIN =
GOEXE =
GOHOSTARCH =amd64
GOHOSTOS =linux
GOOS =linux
GOPATH =/ home / user / .gvm / pkgsets / go1.5.1 / global
GORACE =
GOROOT =/ home / user / .gvm / gos / go1.5.1
GOTOOLDIR =/ home / user / .gvm / gos / go1.5.1 / pkg / tool / linux_amd64
GO15VENDOREXPERIMENT =
CC =gcc
GOGCCFLAGS = - fPIC -m64 -pthread -fmessage-length = 0
CXX =g ++
CGO_ENABLED =1
[user @ pc :〜/ .gvm / pkgsets / go1.5.1 / global]
>> go get golang.org/x/tools/cmd/godoc
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> ls
pkg src
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> go get golang.org/x/tour/gotour
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> ls
bin pkg src
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> ls bin /
gotour
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global]
>> cd src / golang.org / x / tools / cmd / godoc /
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global / src / golang.org / x / tools / cmd / godoc]
>> go build
[user @ pc:〜/ .gvm / pkgsets / go1.5.1 / global / src / golang.org / x / tools / cmd / godoc]
>> ./godoc
用法:godoc包[name ...]
godoc -http =:6060
- 分析字符串
要执行的分析的逗号分隔列表(支持:type ,指针)。请参阅http://golang.org/lib/godoc/analysis/help.html
-ex
在命令行模式下显示示例
-goroot字符串
转到根目录(默认/home/user/.gvm/gos/go1.5.1)
-html
在命令行模式下打印HTML
-http字符串
HTTP服务地址(例如, ':6060')
-httptest.serve字符串
如果非空,则httptest.NewServer服务于此地址并阻止
--index
....
解决方案
Godoc是一种特殊功能,因为它是Go发行版的官方工具。
$ b
所以如果你去得到 godoc,结果二进制文件将不会被放置在 $ GOPATH / bin 其中所有其他可执行文件都在,但在 $ GOROOT / bin 下。
Gotour并不是特殊的,因此它被安装到 $ GOPATH / bin 中。
godoc and gotour can be built and run from their respecitve source directory with go build. What is the reason a gotour binary created when one go get it and that is not the case for godoc.
Command Line Output:
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> ls [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/user/.gvm/pkgsets/go1.5.1/global" GORACE="" GOROOT="/home/user/.gvm/gos/go1.5.1" GOTOOLDIR="/home/user/.gvm/gos/go1.5.1/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1" [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> go get golang.org/x/tools/cmd/godoc [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> ls pkg src [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> go get golang.org/x/tour/gotour [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> ls bin pkg src [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> ls bin/ gotour [ user@pc:~/.gvm/pkgsets/go1.5.1/global ] >> cd src/golang.org/x/tools/cmd/godoc/ [ user@pc:~/.gvm/pkgsets/go1.5.1/global/src/golang.org/x/tools/cmd/godoc ] >> go build [ user@pc:~/.gvm/pkgsets/go1.5.1/global/src/golang.org/x/tools/cmd/godoc ] >> ./godoc usage: godoc package [name ...] godoc -http=:6060 -analysis string comma-separated list of analyses to perform (supported: type, pointer). See http://golang.org/lib/godoc/analysis/help.html -ex show examples in command line mode -goroot string Go root directory (default "/home/user/.gvm/gos/go1.5.1") -html print HTML in command-line mode -http string HTTP service address (e.g., ':6060') -httptest.serve string if non-empty, httptest.NewServer serves on this address and blocks -index ....
解决方案
Godoc is special as it is an official tool being part of the Go distribution.
So if you go get godoc, the result binary will not be placed under $GOPATH/bin where all other executables go, but under $GOROOT/bin.
Gotour is not special in this way, so it gets installed into your $GOPATH/bin.
这篇关于为什么在运行`go get golang.org / x / tools / cmd / godoc`时没有创建二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!