From 218b81c709248784112ae7bd0646c7fc6773fe5f Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 12 Dec 2019 23:53:39 +0000 Subject: fix(external): Skip folders with "no buildable Go files" This error is returned by the build analysis logic if the target package does not have any relevant Go files, which might be the case if `+build` flags and such are used. --- external/main.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/external/main.go b/external/main.go index 23fd53326ed0..e0b95605f0dd 100644 --- a/external/main.go +++ b/external/main.go @@ -43,14 +43,15 @@ func findGoDirs(at string) ([]string, error) { dirSet := make(map[string]bool) err := filepath.Walk(at, func(path string, info os.FileInfo, err error) error { + name := info.Name() // Skip folders that are guaranteed to not be relevant - if info.IsDir() && (info.Name() == "testdata" || info.Name() == ".git") { + if info.IsDir() && (name == "testdata" || name == ".git") { return filepath.SkipDir } // If the current file is a Go file, then the directory is popped // (i.e. marked as a Go directory). - if !info.IsDir() && strings.HasSuffix(info.Name(), ".go") && !strings.HasSuffix(info.Name(), "_test.go") { + if !info.IsDir() && strings.HasSuffix(name, ".go") && !strings.HasSuffix(name, "_test.go") { dirSet[filepath.Dir(path)] = true } @@ -154,6 +155,16 @@ func main() { all := []pkg{} for _, d := range goDirs { analysed, err := analysePackage(*source, d, *path, stdlibPkgs) + + // If the Go source analysis returned "no buildable Go files", + // that directory should be skipped. + // + // This might be due to `+build` flags on the platform and other + // reasons (such as test files). + if _, ok := err.(*build.NoGoError); ok { + continue + } + if err != nil { log.Fatalf("failed to analyse package at %q: %s", d, err) } -- cgit 1.4.1