internal/lsp/source: fix error message for multiple GOPATHs

The current handling of error messages did not address the case that a
user may have multiple directories listed in their GOPATH.

Fixes golang/go#36120

Change-Id: I8e68a45d3dd902975a0ccf4177ec2698accdf69d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211304
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/source/errors.go b/internal/lsp/source/errors.go
index 634e287..e0c1819 100644
--- a/internal/lsp/source/errors.go
+++ b/internal/lsp/source/errors.go
@@ -47,7 +47,16 @@
 
 	// Not inside of a module.
 	inAModule := modFile != ""
-	inGopath := strings.HasPrefix(uri.Filename(), filepath.Join(gopath, "src"))
+
+	// The user may have a multiple directories in their GOPATH.
+	var inGopath bool
+	for _, gp := range filepath.SplitList(gopath) {
+		if strings.HasPrefix(uri.Filename(), filepath.Join(gp, "src")) {
+			inGopath = true
+			break
+		}
+	}
+
 	moduleMode := os.Getenv("GO111MODULE")
 
 	var msg string