<分区>
如何在 Windows 上为 Linux 编译一个 go 文件/项目?
在 Linux 上应该可以通过一行代码实现:
GOOS=windows go build -o filename.exe codefile.go
我通过 Powershell 尝试了类似的操作,但在我的 Linux 服务器(Ubuntu 16.04 amd64)上只出现了一个错误:
-bash: ./gotest: cannot execute binary file: Exec format error".
我尝试使用用户 Env-vars 为 GOOS = linux
和 GOARCH = amd64
并在 Powershell 中通过 set GOOS = linux
,但我对 Powershell 了解不够 - go build 命令运行时没有错误并生成文件。
任何人都可以使用 go-1.10 通过 Powershell(或 cmd)(通过 VS 代码)解释在 Windows (10 1709 x64) 上的一般操作方法吗?