什么是去打造构建? [英] What does go build build?
问题描述
新增设的围棋程序员往往不知道或感到困惑的根本去构建命令做了什么。
New Go programmers often don't know or get confused what the fundamental go build command does.
怎么做完全去建立
和去安装
命令建立和在哪里他们把结果/输出?
What do exactly the go build
and go install
commands build and where do they put the result/output?
推荐答案
什么走
命令不取决于我们是否运行了正常包或为特殊主
包。
What the go
command does depends on whether we run it for a "normal" package or for the special "main"
package.
对于包
-
去建立
建立你的包,那么的放弃的结果的 -
进入安装
构建那么的安装的包在$ GOPATH / PKG
目录
go build
builds your package then discards the results.go install
builds then installs the package in your$GOPATH/pkg
directory.
有关命令(包主
)
For commands (package main
)
-
去建立
构建命令和叶结果在当前工作目录的 -
去安装
在临时目录中生成的命令,然后将其移动到$ GOPATH /斌
。
go build
builds the command and leaves the result in the current working directory.go install
builds the command in a temporary directory then moves it to$GOPATH/bin
.
所以基本上你可以使用去建立
作为检查的包可以建造(以及它们的依赖),而进入安装
也(永久性的)安装在你的 $ GOPATH
适当的文件夹中的结果。
So basically you can use go build
as a check that the packages can be built (along with their dependencies) while go install
also (permanently) installs the results in the proper folders of your $GOPATH
.
去建立
如果一切正常,并给你的错误信息,如果该包不能建立/编译。会悄悄地终止
go build
will silently terminate if everything is ok, and will give you error messages if the packages cannot be built/compiled.
每当走
工具安装包或二进制文件,也安装有任何依赖关系,因此运行去安装
也将安装软件包你的程序依赖于(公开的,走的GetTable包),自动。
Whenever the go
tool installs a package or binary, it also installs whatever dependencies it has, so running go install
will also install packages your program depends on (publicly available, "go gettable" packages), automatically.
首先,阅读官方 如何写围棋code 一>页
For a start, read the official How to Write Go Code page.
有关走
工具的更多信息: 命令去
More information about the go
tool: Command go
您还可以通过运行以下命令获得更多的帮助:
You can also get more help by running the following command:
go help build
这也是值得注意的是,与围棋1.5开始去安装
也删除由创建可执行文件去建立
(< A HREF =https://go-review.googlesource.com/#/c/10682/>来源):
如果'去安装(不带参数,这意味着当前目录)
成功,删除由去建设写入可执行文件,如果present。这避免了留下一个陈旧落后的二进制...
If 'go install' (with no arguments, meaning the current directory) succeeds, remove the executable written by 'go build', if present. This avoids leaving a stale binary behind...
要完成的列表中,去运行,
编译应用程序到临时文件夹,并启动可执行二进制文件。当应用程序存在,它正确地清理临时文件。
To complete the list, go run
compiles your application into a temporary folder, and starts that executable binary. When the app exists, it properly cleans up the temporary files.
<子>由戴维·切尼的什么去建立构建<? / A>
这篇关于什么是去打造构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!