Skip to content

Commit

Permalink
language/go: Handle unix build tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
connyay authored and fmeum committed May 1, 2023
1 parent 07882db commit f382236
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions language/go/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ func matchesOS(os, value string) bool {
if os == value {
return true
}
if value == "unix" {
return rule.UnixOS[os]
}
for _, alias := range rule.OSAliases[os] {
if alias == value {
return true
Expand Down
19 changes: 19 additions & 0 deletions rule/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ var OSAliases = map[string][]string{
"ios": {"darwin"},
}

// UnixOS is the set of GOOS values matched by the "unix" build tag.
// This list is from go/src/cmd/dist/build.go.
var UnixOS = map[string]bool{
"aix": true,
"android": true,
"darwin": true,
"dragonfly": true,
"freebsd": true,
"hurd": true,
"illumos": true,
"ios": true,
"linux": true,
"netbsd": true,
"openbsd": true,
"solaris": true,
}

var (
// KnownOSs is the sorted list of operating systems that Go supports.
KnownOSs []string
Expand Down Expand Up @@ -133,6 +150,8 @@ func init() {
KnownOSArchs[p.OS] = append(KnownOSArchs[p.OS], p.Arch)
KnownArchOSs[p.Arch] = append(KnownArchOSs[p.Arch], p.OS)
}
// unix is a pseudo os
KnownOSSet["unix"] = true
KnownOSs = make([]string, 0, len(KnownOSSet))
KnownArchs = make([]string, 0, len(KnownArchSet))
for os := range KnownOSSet {
Expand Down

0 comments on commit f382236

Please sign in to comment.