how to create a statically linked golang executable with go 1.5+

自古美人都是妖i 提交于 2019-12-04 05:03:56

I hate to answer my own question. The comments have been correct CGO_ENABLED=0 go build ./... seems to have have done the trick.

While it was not part of the original question, once the program started executing in the rkt container it could not perform a proper DNS request. So there must be something else going on too.

Static linking:

Go 1.5:

go build -ldflags "-extldflags -static" ...

With Go 1.6 I had to use:

go build -ldflags "-linkmode external -extldflags -static" ...
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!