什么是去打造构建? [英] What does go build build?

查看:324
本文介绍了什么是去打造构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新增设的围棋程序员往往不知道或感到困惑的根本去构建命令做了什么。

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?

推荐答案

这个Q&安培; A是的知识共享/记录

什么命令不取决于我们是否运行了正常包或为特殊包。

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 =htt​​ps://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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆