问题描述
我在Windows 10上安装了GO 1.7。我创建了测试程序,它在Windows中完美运行。下一步是尝试使用Ubuntu在我的docker虚拟机上运行它。
我发现
问题是在哪里以及如何在Linux上下载它?也许那就是我正在做的事情是完全错误的方式...
更新2017年9月2日
我按照建议运行
set GOARCH = amd64
set GOOS = linux
go build -o myapp
将文件复制到共享文件夹后,复制表格到另一个不共享的文件夹(以避免出现
如果您使用Visual Studio Code进行开发,不要忘记重新启动它。
更新2017年2月24日
取而代之的是,您可以在Windows powershell中像这样设置变量
并读入控制台
I have GO 1.7 installed on my Windows 10. I created test program and it works perfectly in Windows. Next step is to try to run it on my docker virtual machine with Ubuntu.
I found here some info about the way to do it
set GOARCH=amd64
set GOOS=linux
go tool dist install -v pkg/runtime
go install -v -a std
I run line 1 and 2 in cmd and there is no problem. At line 3 I have an error
go tool dist: open C:\Go\src\pkg\runtime: The system cannot find the path specified.
I check manually this folder and there is a runtime only for windows
The question is where and how can I download it for linux? Or maybe thats I'm doing is completely wrong way...
UPDATE 09/02/2017
I ran like it was suggested
set GOARCH=amd64
set GOOS=linux
go build -o "myapp"
After I copied this file to shared folder, copied form there to another not shared folder (to avoid an issue described here) and executed
root@7dd1655ae5db:/__notshared# ./myapp
bash: ./myapp: cannot execute binary file: Exec format error
After I downloaded file package checked my file
root@7dd1655ae5db:/__notshared# file myapp
myapp: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
It seems that during build not linux executable was created.
I found a problem and a solution of it.
In my Windows 10 these commands
set GOARCH=amd64
set GOOS=linux
in cmd and also in powershell console did really nothing! Only the way it works is that I need to open Control Panel -> System -> System Advanced Settings -> Environment Variables and add them there manually.
If you use Visual Studio Code for development, do not forget to restart it.
UPDATE 24/02/2017
Instead all above you can set variable in windows powershell like this
and read it to console
这篇关于从Windows到Linux / Ubuntu进行1.7交叉编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!