我们可以将在Ubuntu上生成的go build输出运行在Windows上吗?

huangapple go评论90阅读模式
英文:

Can we run the output of go build generated from ubuntu to windwos

问题

我是你的中文翻译助手,以下是你要翻译的内容:

我对Go语言还不熟悉,如果我说错了,请纠正我。由于Go可执行文件是静态链接的,所以我可以在Windows上编写代码,并在同一台机器上构建它,但在部署时使用Linux(Ubuntu)吗?这样做是否可行,或者我漏掉了什么?

英文:

I am new to Go, so correct me if, i am wrong. Since Go executable are statically linked. So, can i code in windows as well as build it on the same but at the time of deployment if i use Linux (ubuntu). So, is it possible to do so or i am missing something here.

答案1

得分: 2

可以的,但比你描述的要复杂一些。不论是否进行静态编译,Go编译器都可以将代码从任何平台生成到任何平台。

关于如何进行交叉编译的快速指南,可以参考这篇文章:http://dave.cheney.net/2015/03/03/cross-compilation-just-got-a-whole-lot-better-in-go-1-5

英文:

It is possible, but a bit more complex than what you describe. Regardless of statically compiling, the Go compiler can generate code from any platform to any platform.

For a quick guide on how to do it, see this article http://dave.cheney.net/2015/03/03/cross-compilation-just-got-a-whole-lot-better-in-go-1-5

huangapple
  • 本文由 发表于 2016年4月15日 18:19:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/36644477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定