internal/lsp: modify check for a missing package

Trying again. Apparently it's useful to run tests before submitting
code.

Change-Id: I487ffd391663cba47d2b26e8346cc7ac589dcd1a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184041
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go
index 913ef4a..789784d 100644
--- a/internal/lsp/cache/load.go
+++ b/internal/lsp/cache/load.go
@@ -118,7 +118,8 @@
 			return nil, pkg.Errors, fmt.Errorf("package %s has errors, skipping type-checking", pkg.PkgPath)
 		}
 		for importPath, importPkg := range pkg.Imports {
-			if len(importPkg.Errors) > 0 {
+			// If we encounter a package we cannot import, mark it as missing.
+			if importPkg.PkgPath != "unsafe" && len(importPkg.CompiledGoFiles) == 0 {
 				if f.missingImports == nil {
 					f.missingImports = make(map[packagePath]struct{})
 				}