src/goDebugConfiguration: expand '~' in cwd attribute

Respect the '~' in a users folder path. Delve will not accept
file paths with '~' as the cwd so we expand it on the extension
side.

Fixes golang/vscode-go#116

Change-Id: Idd89a01a2c362029b56f382a0207b0381c0d7598
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/252657
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts
index 983269f..e4528ab 100644
--- a/src/goDebugConfiguration.ts
+++ b/src/goDebugConfiguration.ts
@@ -11,7 +11,7 @@
 import { promptForMissingTool } from './goInstallTools';
 import { packagePathToGoModPathMap } from './goModules';
 import { getFromGlobalState, updateGlobalState } from './stateUtils';
-import { getBinPath, getCurrentGoPath, getGoConfig } from './util';
+import { getBinPath, getGoConfig, resolvePath } from './util';
 import { parseEnvFiles } from './utils/envUtils';
 
 export class GoDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
@@ -90,6 +90,10 @@
 		if (debugConfiguration.request === 'attach' && !debugConfiguration['cwd']) {
 			debugConfiguration['cwd'] = '${workspaceFolder}';
 		}
+		if (debugConfiguration['cwd']) {
+			// expand 'cwd' folder path containing '~', which would cause dlv to fail
+			debugConfiguration['cwd'] = resolvePath(debugConfiguration['cwd']);
+		}
 
 		debugConfiguration['dlvToolPath'] = getBinPath('dlv');
 		if (!path.isAbsolute(debugConfiguration['dlvToolPath'])) {