go/analysis: validate report if analyzer.Run is empty

The Run function is necessary for an analyzer, if left a nil Run, the runner will panic in run-time(singlechecker.Main, etc).

Change-Id: Ibbeea2d8c740f73e6c083647df6ded445036e272
Reviewed-on: https://go-review.googlesource.com/c/tools/+/329451
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/go/analysis/validate.go b/go/analysis/validate.go
index 23e57bf..9da5692 100644
--- a/go/analysis/validate.go
+++ b/go/analysis/validate.go
@@ -14,6 +14,8 @@
 // Validate reports an error if any of the analyzers are misconfigured.
 // Checks include:
 // that the name is a valid identifier;
+// that the Doc is not empty;
+// that the Run is non-nil;
 // that the Requires graph is acyclic;
 // that analyzer fact types are unique;
 // that each fact type is a pointer.
@@ -46,6 +48,9 @@
 				return fmt.Errorf("analyzer %q is undocumented", a)
 			}
 
+			if a.Run == nil {
+				return fmt.Errorf("analyzer %q has nil Run", a)
+			}
 			// fact types
 			for _, f := range a.FactTypes {
 				if f == nil {