dpvmtdu364462 2015-09-17 09:38
浏览 141

Golang可执行文件大小

I've searched for recent information on building compact Go executables, without success. Most information appears to be several years old.

My program: the standard hello world as found on Rosettacode.org. With Fortran I get an exe file under 100 KB. With Go the exe file is whopping 2400 KB.

My questions: are there compiler switches or pragmas that I should be using? Are there other tools or tricks I am not aware of (I am a beginner with Go). What are the future plans for Go regarding executable size? What is it like under Linux - same thing? What happens to exe files on large programs?

Background: I'm using go 1.5 installed on Windows 7. My project is writing (actually migrating from other languages) some command line programs. Having 20 or more large Go exe files eats up a lot of space. OK, I know space is cheap so I can live with it. However, I believe clarity on the matter will help many people.

  • 写回答

2条回答 默认 最新

  • dongxuying7583 2015-09-17 09:50
    关注

    A Go program is big because it contains garbage collaction code, goroutine scheduling code and besides that it has nearly all libraries statically linked. It is so by design.

    FAQ Why is my trivial program such a large binary

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器