dory4404 2013-12-22 11:12 采纳率: 0%
浏览 43
已采纳

所有可能的GOOS值?

If I get it right, GOOS is determined when compile the source code.

To better support multiple OS, I'm interested in what GOOS could be.

Of course, there might be infinite possibilities of it, since Go is opensourced. So what I really want is a "common list".

Known values are:

  • windows
  • linux
  • darwin or freebsd or unix? I know that at least one of them must exist.
  • 写回答

3条回答 默认 最新

  • dongwen7813 2015-05-06 05:27
    关注

    Note that those values are defined in src/go/build/syslist.go.

    With Go 1.5 (Q3 2015), GOARCH will become much more complete.
    See commit 1eebb91 by Minux Ma (minux)

    go/build: reserve GOARCH values for all common architectures

    Whenever we introduce a new GOARCH, older Go releases won't recognize them and this causes trouble for both our users and us (we need to add unnecessary build tags).

    Go 1.5 has introduced three new GOARCHes so far: arm64 ppc64 ppc64le, we can take the time to introduce GOARCHes for all common architectures that Go might support in the future to avoid the problem.

    const goosList = "android darwin dragonfly freebsd linux nacl \ 
      netbsd openbsd plan9 solaris windows "
    
    const goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le \
       mips mipsle mips64 mips64le mips64p32 mips64p32le \ # (new)
       ppc s390 s390x sparc sparc64 " # (new)
    

    The list is still being review in Change 9644, with comments like:

    I wouldn't bother with Itanium. It's basically a dead architecture.
    Plus, it's so hard to write a compiler for it that I really can't see it happening except as a labor of love, and nobody loves the Itanium.

    The official documentation now (GO 1.5+ Q3 2015) reflects that completed list.


    Update 2018: as documented in Giorgos Oikonomou's answer, Go 1.7 (Q1 2016) has introduced the
    go tool dist list command.
    See commit c3ecded: it fixes issue 12270 opened in Q3 2015:

    To easier write tooling for cross compiling it would be good to programmatically get the possible combinations of GOOS and GOARCH.

    This was implemented in CL 19837

    cmd/dist: introduce list subcommand to list all supported platforms

    You can list in plain text, or in json:

    > go tool dist list -json
    [
            {
                    "GOOS": "android",
                    "GOARCH": "386",
                    "CgoSupported": true
            },
            ...
    ]
    

    As Mark Bates tweeted:

    Bonus: Column output properly formatted for display:

    go tool dist list | column -c 75 | column -t
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能