diff --git a/language/go/fileinfo.go b/language/go/fileinfo.go index 990f5070f..8e6fe266b 100644 --- a/language/go/fileinfo.go +++ b/language/go/fileinfo.go @@ -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 @@ -556,8 +559,7 @@ func checkConstraints(c *config.Config, os, arch, osSuffix, archSuffix string, t if isIgnoredTag(tag) { return true } - - if _, ok := rule.KnownOSSet[tag]; ok { + if _, ok := rule.KnownOSSet[tag]; ok || tag == "unix" { if os == "" { return false } diff --git a/rule/platform.go b/rule/platform.go index 2d797672d..fffac4799 100644 --- a/rule/platform.go +++ b/rule/platform.go @@ -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