gpt4 book ai didi

go - 所有可能的 GOOS 值?

转载 作者:行者123 更新时间:2023-12-01 22:27:53 33 4
gpt4 key购买 nike

如果我猜对了,GOOS在编译源代码时确定。

为了更好地支持多个操作系统,我对 GOOS 感兴趣可能。

当然,它可能有无限的可能性,因为 Go 是开源的。所以我真正想要的是一个“共同 list ”。

已知值为:

  • windows
  • linux
  • darwinfreebsdunix ?我知道其中至少有一个必须存在。
  • 最佳答案

    请注意,这些值定义在:

  • src/go/build/syslist.go , 和
  • doc/install/source#environment .

  • 使用 Go 1.5(2015 年第三季度), GOARCH会变得更加完整。
    commit 1eebb91Minux 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)
    Change 9644 中的列表仍在审核中,评论如下:

    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.


    official documentation现在(GO 1.5+ Q3 2015)反射(reflect)了已完成的列表。

    2018 年更新:如 Giorgos Oikonomou 中所述的 answer , Go 1.7 (Q1 2016) 引入了
    go tool dist list 命令。
    commit c3ecded :它修复了 issue 12270 2015 年第三季度开业:

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


    这是在 CL 19837 中实现的。

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


    您可以以纯文本或 json 格式列出:
    > go tool dist list -json
    [
    {
    "GOOS": "android",
    "GOARCH": "386",
    "CgoSupported": true
    },
    ...
    ]
    Mark Bates tweeted :

    Bonus: Column output properly formatted for display:

    go tool dist list | column -c 75 | column -t

    关于go - 所有可能的 GOOS 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58785917/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com