go - 使 GO 构建适应不同的操作系统

标签 go command-line-interface cloud-foundry

我需要评估“GO”以满足我构建可在不同操作系统中运行的 CLI 工具的要求。这是如何在“Cloud Foundry CLI”等 CLI 工具中实现的? GO 如何适应操作系统?

最佳答案

Go 可以从任何操作系统构建到任何操作系统。您可以使用两个名为 GOOSGOARCH 的环境变量来控制操作系统和体系结构。前者是操作系统,后者是CPU架构。

64 位 Linux 的build设置为:

GOARCH=amd64
GOOS=linux

GOARCH 的选项有 386、amd64arm

GOOS 的选项有 darwin、dragonfly、freebsd、linux、netbsd、openbsd、plan9、solariswindows

启用交叉编译还有几个步骤,这里有更详细的描述:http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go

关于go - 使 GO 构建适应不同的操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30014421/

相关文章:

go - 为什么 math.Pow 的性能比位移差?

dictionary - 将 map 的所有元素复制到另一个 map 中

python - python多线程同时打印和输入

database - 针对现有数据库使用 derby ij

java - Pivot Cloud Foundry 错误 : "Browser detection failed and system property h2.browser not set" - Spring Boot 2

json - 在 JSON 对象中发送数组时出错

戈朗 : Is there a way to modify one of the multi-value return parameters in one line?

python - 交互式 CLI 包 - 复选框和选择

amazon-web-services - 获取 Bluemix 实例 IP

eclipse - 与服务器通信失败 : 500 Internal server error and no log files