Revert "src: skip version check for golangci-lint"

This reverts commit bca140410bbf79f18c7b1b970b662a7eca947f44.

Reason for revert: golang/vscode-go#3949

Change-Id: I11b3f1c31a06b098b1a00d98328d512ee5a479c3
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/733940
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Madeline Kalil <mkalil@google.com>
diff --git a/extension/src/goLint.ts b/extension/src/goLint.ts
index cf2ba90..b13feec 100644
--- a/extension/src/goLint.ts
+++ b/extension/src/goLint.ts
@@ -9,7 +9,8 @@
 import { getGoConfig } from './config';
 import { toolExecutionEnvironment } from './goEnv';
 import { diagnosticsStatusBarItem, outputChannel } from './goStatus';
-import { getWorkspaceFolderPath, handleDiagnosticErrors, ICheckResult, resolvePath, runTool } from './util';
+import { inspectGoToolVersion } from './goInstallTools';
+import { getBinPath, getWorkspaceFolderPath, handleDiagnosticErrors, ICheckResult, resolvePath, runTool } from './util';
 
 /**
  * Runs linter on the current file, package or workspace.
@@ -112,9 +113,14 @@
 		args.push(flag);
 	});
 	if (linter.startsWith('golangci-lint')) {
-		let version = 1;
+		let version: number;
 		if (linter === 'golangci-lint-v2') {
 			version = 2;
+		} else {
+			const { moduleVersion } = await inspectGoToolVersion(getBinPath(linter));
+			// if moduleVersion is undefined, treat it as version=1
+			// if moduleVersion is higher than v1 (v2, v3...), treat it as version=2
+			version = !moduleVersion || moduleVersion.startsWith('v1') ? 1 : 2;
 		}
 
 		// append common flags