src/utils/wmicProcessParser.ts: get exe path from wmic

Get the executable path from the wmic output to be used
to determine if process is running go.

Updates golang/vscode-go#183

Change-Id: I6894897d8a4744498f14154b03da89110a7ef567
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/288172
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/pickProcess.ts b/src/pickProcess.ts
index f17815b..2766550 100644
--- a/src/pickProcess.ts
+++ b/src/pickProcess.ts
@@ -60,12 +60,12 @@
 
 async function getGoProcesses(): Promise<AttachItem[]> {
 	const processes = await getAllProcesses();
-	// TODO(suzmue): set the executable path for win32 and darwin.
-	if (process.platform !== 'linux') {
+	// TODO(suzmue): set the executable path for and darwin.
+	if (process.platform === 'darwin') {
 		return processes;
 	}
 
-	// Run 'go version' on all of /proc/${pid}/exe to find 'go' processes
+	// Run 'go version' on all executable paths to find 'go' processes
 	const goRuntimePath = getBinPath('go');
 	if (!goRuntimePath) {
 		vscode.window.showErrorMessage(
@@ -94,7 +94,7 @@
 
 	const goProcesses: AttachItem[] = [];
 	processes.forEach((item) => {
-		if (goProcessExes.indexOf(item.id) >= 0) {
+		if (goProcessExes.indexOf(item.executable) >= 0) {
 			item.isGo = true;
 			goProcesses.push(item);
 		}
diff --git a/src/utils/wmicProcessParser.ts b/src/utils/wmicProcessParser.ts
index 9b20883..721b39d 100644
--- a/src/utils/wmicProcessParser.ts
+++ b/src/utils/wmicProcessParser.ts
@@ -4,8 +4,9 @@
  * Licensed under the MIT License. See LICENSE in the project root for license information.
  *--------------------------------------------------------*/
 
-// Taken from:
-// https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/extension/attachQuickPick/wmicProcessParser.ts
+// Modified from:
+// https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/extension/attachQuickPick/wmicProcessParser.ts.
+// Added arguments to get the ExecutablePath from wmic.
 
 'use strict';
 
@@ -14,6 +15,7 @@
 const wmicNameTitle = 'Name';
 const wmicCommandLineTitle = 'CommandLine';
 const wmicPidTitle = 'ProcessId';
+const wmicExecutableTitle = 'ExecutablePath';
 const defaultEmptyEntry: AttachItem = {
 	label: '',
 	description: '',
@@ -32,7 +34,7 @@
 // |		   1308 |	  1132 |
 export const wmicCommand: ProcessListCommand = {
 	command: 'wmic',
-	args: ['process', 'get', 'Name,ProcessId,CommandLine', '/FORMAT:list']
+	args: ['process', 'get', 'Name,ProcessId,CommandLine,ExecutablePath', '/FORMAT:list']
 };
 
 export function parseWmicProcesses(processes: string): AttachItem[] {
@@ -79,6 +81,8 @@
 
 			currentItem.detail = value;
 			currentItem.commandLine = value;
+		} else if (key === wmicExecutableTitle) {
+			currentItem.executable = value;
 		}
 	}