Go中没有安装gotype命令?

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

gotype command not installed with Go?

问题

我从外部网站得到了Go 1.4 / Win32版本。我看到了文件夹"c:\go\bin",但里面没有gotype命令。我需要gotype命令,请问gotype在哪里,如何安装它?

英文:

i got Go 1.4 / Win32 from offsite. I see foder "c:\go\bin". No gotype command in it. I need gotype -- where is gotype, how to install it?

答案1

得分: 3

2015年4月更新:Go 1.5应该引入了"go doc"命令,请参见以下链接:

> 将新的"go doc"命令添加到go命令中,安装在工具目录中。

> 用法:

go doc [-u] [package|[package.]symbol[.method]]

原始答案(2015年1月)

你需要:

go get -u golang.org/x/tools/cmd/gotype

这将安装来自golang.org/x/tools/cmd/gotype的额外工具:

> "gotype"命令对Go文件和包进行语法和语义分析,就像Go编译器的前端一样。
如果分析失败,则报告错误;否则,gotype是静默的(除非设置了"-v")。


注意:这不是你可能考虑安装的唯一额外工具,如这篇文章所示:

go get -u golang.org/x/tools/cmd/godoc
go get -u golang.org/x/tools/cmd/vet
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/tools/cmd/gorename
go get -u golang.org/x/tools/cmd/oracle
go get -u golang.org/x/tools/cmd/gotype
go get -u github.com/golang/lint/golint

注意:Go 1.5将使该操作更快。
请参见Brad Fitzpatrick (bradfitz)提交 dc2d64b

> ## cmd/go: 缓存元标签发现期间执行的HTTP请求的结果

> 以前,运行

$ go get -u -v golang.org/x/tools/cmd/godoc

> 会导致针对x/tools下的每个包进行数十个HTTP请求:

https://golang.org/x/tools?go-get=1

> 现在它缓存了结果。
我们仍然会对x/tools下的所有包执行一次HTTP请求,但这将减少总共约一半的HTTP请求次数。

英文:

Update April 2015: Go 1.5 should introduce "go doc": see

  • review 9227: cmd/go,cmd/doc: add "go doc"
  • review 9226: rename doc.go to alldocs.go in preparation for "go doc"

> Add the new go doc command to the go command, installed in the tool directory.

> usage:

go doc [-u] [package|[package.]symbol[.method]]

Original answer (January 2015)

You would need:

go get -u golang.org/x/tools/cmd/gotype

That would install that extra tools from golang.org/x/tools/cmd/gotype:

> The gotype command does syntactic and semantic analysis of Go files and packages like the front-end of a Go compiler.
Errors are reported if the analysis fails; otherwise gotype is quiet (unless -v is set).


Note: this isn't the only extra tool you might consider installing, as illustrated in this article:

go get -u golang.org/x/tools/cmd/godoc
go get -u golang.org/x/tools/cmd/vet
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/tools/cmd/gorename
go get -u golang.org/x/tools/cmd/oracle
go get -u golang.org/x/tools/cmd/gotype
go get -u github.com/golang/lint/golint

Note: Go 1.5 will make that operation even faster.
See commit dc2d64b by Brad Fitzpatrick (bradfitz):

> ## cmd/go: cache results of HTTP requests done during meta tag discovery

> Previously, running

$ go get -u -v golang.org/x/tools/cmd/godoc

> would results in dozens of HTTP requests for:

https://golang.org/x/tools?go-get=1

> once per package under x/tools.

> Now it caches the results.
We still end up doing one HTTP request for all the packages under x/tools, but this reduces the total number of HTTP requests in ~half.

huangapple
  • 本文由 发表于 2015年1月5日 02:39:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/27768974.html
匿名

发表评论

匿名网友

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

确定