summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-09-30 14:45:28 -0700
committergVisor bot <gvisor-bot@google.com>2021-09-30 14:49:19 -0700
commitc122663548b9bf4bc46843cc662ea8d7e96e7676 (patch)
tree0c673fd44db5db64166442dfdf7fe0b67724e3d7 /tools
parentb4d4f4bd861c98feb0e28d637ef701b9f7f1840e (diff)
Skip analysis of standard library packages using generics
The upstream analysis packages we depend on do not yet support analysis of code using Go 1.18 type parameter features, making analysis of the Go tip standard library choke and crash. Skip these packages for now. PiperOrigin-RevId: 400030256
Diffstat (limited to 'tools')
-rw-r--r--tools/nogo/nogo.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/nogo/nogo.go b/tools/nogo/nogo.go
index d95d7652f..2f88f84db 100644
--- a/tools/nogo/nogo.go
+++ b/tools/nogo/nogo.go
@@ -293,6 +293,19 @@ func CheckStdlib(config *StdlibConfig, analyzers []*analysis.Analyzer) (allFindi
break
}
+ // Go standard library packages using Go 1.18 type parameter features.
+ //
+ // As of writing, analysis tooling is not updated to support type
+ // parameters and will choke on these packages. We skip these packages
+ // entirely for now.
+ //
+ // TODO(b/201686256): remove once tooling can handle type parameters.
+ usesTypeParams := map[string]struct{}{
+ "constraints": struct{}{}, // golang.org/issue/45458
+ "maps": struct{}{}, // golang.org/issue/47649
+ "slices": struct{}{}, // golang.org/issue/45955
+ }
+
// Aggregate all files by directory.
packages := make(map[string]*PackageConfig)
for _, file := range config.Srcs {
@@ -306,10 +319,17 @@ func CheckStdlib(config *StdlibConfig, analyzers []*analysis.Analyzer) (allFindi
continue // Not a file.
}
pkg := d[len(rootSrcPrefix):]
+
// Skip cmd packages and obvious test files: see above.
if strings.HasPrefix(pkg, "cmd/") || strings.HasSuffix(file, "_test.go") {
continue
}
+
+ if _, ok := usesTypeParams[pkg]; ok {
+ log.Printf("WARNING: Skipping package %q: type param analysis not yet supported", pkg)
+ continue
+ }
+
c, ok := packages[pkg]
if !ok {
c = &PackageConfig{