internal/fetch: process packages with underscores
If a package's import path contains a directory that begins with an
underscore, then process the package.
Before we didn't, because the go tool's wildcard patterns ignore such
packages. But they can be perfectly usable.
Change-Id: I467a25758fafc6d23696a7155ab0afeea31e376e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/284232
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/fetch/package.go b/internal/fetch/package.go
index 314bef3..1a6edcf 100644
--- a/internal/fetch/package.go
+++ b/internal/fetch/package.go
@@ -246,9 +246,13 @@
// Directory and file names that begin with "." or "_" are ignored
// by the go tool, as are directories named "testdata".
//
+// However, even though `go list` and other commands that take package
+// wildcards will ignore these, they can still be imported and used in
+// working Go programs. We continue to ignore the "." and "testdata"
+// cases, but we've seen valid Go packages with "_", so we accept those.
func ignoredByGoTool(importPath string) bool {
for _, el := range strings.Split(importPath, "/") {
- if strings.HasPrefix(el, ".") || strings.HasPrefix(el, "_") || el == "testdata" {
+ if strings.HasPrefix(el, ".") || el == "testdata" {
return true
}
}