go build ./... doesn't build binaries?

xuanbao · · 977 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi all,</p> <p>Here is an example project:</p> <pre><code>$GOPATH/src/project: - foo |- main.go - bar |- main.go </code></pre> <p>If I cd into foo/, run <em>go build</em>, it prodices <em>foo</em> binary in the foo/ directory. The same for bar.</p> <p>But, if I run &#34;go build -v ./...&#34; in the project&#39;s root, I get the following output, and have no binaries:</p> <pre><code>$ go build -v ./... project/bar project/foo $ find . . ./bar ./bar/main.go ./foo ./foo/main.go </code></pre> <p><em>go build ./...</em> for subdirs produces no binaries at all. <em>go help packages</em> do not help to understand it.</p> <p>So, is it designed to be like that on purpose?</p> <p>EDIT: found in go help build:</p> <blockquote> <p>When the command line specifies a single main package, build writes the resulting executable to output. Otherwise build compiles the packages but discards the results, serving only as a check that the packages can be built.</p> </blockquote> <hr/>**评论:**<br/><br/>: <pre><p>[deleted]</p></pre>divan0: <pre><p>Well, I&#39;m aware of go install ./..., but the point is &#39;go build&#39; command is a synonym for &#39;compile and get binary in current dir&#39;, so I do expect the same when I run with ./...</p> <p>Now, I see in <em>go help build</em> this behavior is described, but I still wonder why it&#39;s made so. Why not build binaries for multiple packages as well on <em>go build ./...</em>?</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

977 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传