doujubeng2942 2015-05-03 13:35
浏览 192
已采纳

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

I need to evaluate 'GO' for my requirement of building a CLI tool which should be runnable in different OS s. How is this achieved in the CLI tools such as 'Cloud Foundry CLI'? How does GO handle this adaption into OSs?

  • 写回答

1条回答 默认 最新

  • dougang1967 2015-05-03 14:08
    关注

    Go can build from any OS to any OS. You control the OS and architecture with two environment variables, named GOOS and GOARCH. The former is the operating system, and the latter is the CPU architecture.

    Building for 64-bit Linux is set as:

    GOARCH=amd64
    GOOS=linux
    

    The options for GOARCH are 386, amd64 and arm.

    The options for GOOS are darwin, dragonfly, freebsd, linux, netbsd, openbsd, plan9, solaris and windows

    There are a few more steps to enabling cross compilation, they are described in more detail here: http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式