在Windows机器上运行IDE,但在Linux机器上测试/运行应用程序? [英] Go IDE on Windows machine, but test/run application on Linux machine?

查看:91
本文介绍了在Windows机器上运行IDE,但在Linux机器上测试/运行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的工作站在Windows上,我使用JetBrains IDE进行开发。通常,我已经将网络磁盘(通过SSH)安装到Linux机器上。这个环境非常适合使用PHP,Javascript(Node),Python等解释型语言进行编码和调试。但对于像Go这样的编译语言来说,这绝对是丑陋的。



为了编写Go代码,我使用了IntelliJ IDEA的Go插件。是否可以为此插件定义远程Go编译器(将在远程Linux机器上运行它)?

解决方案

由于Go是一种编译语言,这种开发设置并不像脚本语言那么容易。要在Windows下编译Linux二进制文件,必须建立一个交叉编译环境。您可以从golang.org下载的二进制包仅支持它们运行的​​平台(即Windows编译器仅生成Windows二进制文件),因此您必须从源代码编译Go。 这篇博文给出了一个很好的交叉编译的介绍 - 确保也阅读注意事项部分,以防万一这些适用于您的情况。如本文所述构建Go之后,您将拥有名为go-linux-amd64(go- [os] - [architecture])的go工具的克隆,您可以使用它来编译二进制文件其他平台。



编辑: Dave Cheney写了另一篇博客文章关于Go 1.5中可用的交叉编译这是在八月)。

I'm doing my first steps with Go.

My workstation is on Windows and I'm using JetBrains IDE for development. Usually, I have mounted network disk (via SSH) to Linux machine. This environment it is pretty comfortable for coding and debugging with interpreted languages like PHP, Javascript (for Node), Python. But it is absolutely ugly for compiled languages like Go.

To write Go code I'm using the Go plugin for IntelliJ IDEA. Is it possible to define a remote Go compiler for this plugin (will run it on remote Linux machine)?

解决方案

Since Go is a compiled language, this kind of development setup is not as easy as with scripting languages. To compile a Linux binary under Windows, you have to set up a cross compilation environment. The binary packages you can download from golang.org only support the platforms they run on (i.e. the Windows compiler only produces Windows binaries), so you'll have to compile Go from source. This blog post gives a good introduction to cross compiling - make sure to also read the "caveats" section, just in case these apply to your situation. After building Go as described in the article, you will have "clones" of the "go" tool named "go-linux-amd64" ("go-[os]-[architecture]") which you can use to compile binaries for other platforms.

Edit: Dave Cheney has written another blog post on the much improved cross compilation available in Go 1.5 (which is due in August).

这篇关于在Windows机器上运行IDE,但在Linux机器上测试/运行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆