Skip to content

Commit

Permalink
imports: add 'UnixOS' list of Unix-like systems
Browse files Browse the repository at this point in the history
From Go 1.19, the build constraint 'unix' proposed in golang/go#20322 is
satisfied by any sufficiently Unix-like value of GOOS, as defined by
src/go/build/syslist.go. This commit adds a 'UnixOS' list containing the
values of GOOS that would satisfy the 'unix' constraint in Go 1.19.
  • Loading branch information
bitfield committed Jul 24, 2022
1 parent 9d15b66 commit f4e7d68
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions imports/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,26 @@ func MatchFile(name string, tags map[string]bool) bool {
return true
}

var KnownOS = make(map[string]bool)
var KnownArch = make(map[string]bool)
var (
KnownOS = make(map[string]bool)
UnixOS = make(map[string]bool)
KnownArch = make(map[string]bool)
)

func init() {
for _, v := range strings.Fields(goosList) {
KnownOS[v] = true
}
for _, v := range strings.Fields(unixList) {
UnixOS[v] = true
}
for _, v := range strings.Fields(goarchList) {
KnownArch[v] = true
}
}

const goosList = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos "
const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc ppc64 ppc64le riscv riscv64 s390 s390x sparc sparc64 wasm "
const (
goosList = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos "
unixList = "aix android darwin dragonfly freebsd hurd illumos ios linux netbsd openbsd solaris "
goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc ppc64 ppc64le riscv riscv64 s390 s390x sparc sparc64 wasm "
)

0 comments on commit f4e7d68

Please sign in to comment.