var (
goos, goarch string
+ cgoEnabled bool
// dirs are the directories to look for *.go files in.
// TODO(bradfitz): just use all directories?
goos = getenv("GOOS", runtime.GOOS)
goarch = getenv("GOARCH", runtime.GOARCH)
+ cgoEnv, err := exec.Command(goTool(), "env", "CGO_ENABLED").Output()
+ if err == nil {
+ cgoEnabled, _ = strconv.ParseBool(strings.TrimSpace(string(cgoEnv)))
+ }
findExecCmd()
}
type context struct {
- GOOS string
- GOARCH string
- noOptEnv bool
+ GOOS string
+ GOARCH string
+ cgoEnabled bool
+ noOptEnv bool
}
// shouldTest looks for build tags in a source file and returns
}
gcFlags := os.Getenv("GO_GCFLAGS")
ctxt := &context{
- GOOS: goos,
- GOARCH: goarch,
- noOptEnv: strings.Contains(gcFlags, "-N") || strings.Contains(gcFlags, "-l"),
+ GOOS: goos,
+ GOARCH: goarch,
+ cgoEnabled: cgoEnabled,
+ noOptEnv: strings.Contains(gcFlags, "-N") || strings.Contains(gcFlags, "-l"),
}
words := strings.Fields(line)
}
}
+ if name == "cgo" && ctxt.cgoEnabled {
+ return true
+ }
+
if name == ctxt.GOOS || name == ctxt.GOARCH || name == "gc" {
return true
}