src/language/goLanguageServer: do not require gopls when language server is disabled

This fixes a bug that made the extension to look up the path to the gopls
binary when go.useLanguageServer is false. During the lookup, if the gopls wasn't
available, getLanguageServerToolPath eventually triggerred the missing tool prompt
and that was not appropriate. Return from buildLanguageServerConfig early
if we don't need the language server.

Updates golang/vscode-go#2300

Change-Id: I7572244350f953c8ce874086f4f5cbb45a7301af
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414456
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/language/goLanguageServer.ts b/src/language/goLanguageServer.ts
index 83bee23..8561b25 100644
--- a/src/language/goLanguageServer.ts
+++ b/src/language/goLanguageServer.ts
@@ -798,6 +798,12 @@
 		env: toolExecutionEnvironment(),
 		checkForUpdates: getCheckForToolsUpdatesConfig(goConfig)
 	};
+	// user has opted out of using the language server.
+	if (!cfg.enabled) {
+		return cfg;
+	}
+
+	// locate the configured language server tool.
 	const languageServerPath = getLanguageServerToolPath();
 	if (!languageServerPath) {
 		// Assume the getLanguageServerToolPath will show the relevant
@@ -808,10 +814,6 @@
 	cfg.path = languageServerPath;
 	cfg.serverName = getToolFromToolPath(cfg.path) ?? '';
 
-	if (!cfg.enabled) {
-		return cfg;
-	}
-
 	// Get the mtime of the language server binary so that we always pick up
 	// the right version.
 	const stats = fs.statSync(languageServerPath);