<p>For example, the following code generate a 2.37mb file.</p>
<pre><code>package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World")
}
</code></pre>
<hr/>**评论:**<br/><br/>lstokeworth: <pre><p>FAQ: <a href="https://golang.org/doc/faq#Why_is_my_trivial_program_such_a_large_binary" rel="nofollow">Why is my trivial program such a large binary?</a></p></pre>: <pre><p>[deleted]</p></pre>skarlso: <pre><p>To the top with this comment.</p></pre>lstokeworth: <pre><p>What did the deleted comment say?</p></pre>skarlso: <pre><p>Basically, RTFM. :-) it is such a simple question that typing it in and submitting took more time than typing it in to Google which would have yielded an answer immediately. </p></pre>scharty: <pre><p>If it's any consolation, it doesn't grow super fast. If you get it to print hello world twice, or won't be 4.6 megs.</p></pre>babawere: <pre><p>It's been improved at the moment see <a href="https://github.com/golang/go/issues/6853" rel="nofollow">
all: binaries too big and growing #6853</a></p></pre>tu_1t_le: <pre><p>try this : </p>
<pre><code>package main
func main() {
print("Hello World")
}
</code></pre></pre>dchapes: <pre><p>It's a <em>really</em> bad idea to recommend the built-in <a href="https://golang.org/pkg/builtin/#print" rel="nofollow">print</a> function(s) to Go newcomers (and you meant <code>println</code> anyway). More importantly, it doesn't address the real reason behind the OP's FAQ (omitting <code>fmt</code> only saves ~1 MB, and understanding why is part of the question).</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传