Use go run . when program points to directory #3096
diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts
index fc3f263..d1145a4 100644
--- a/src/debugAdapter/goDebug.ts
+++ b/src/debugAdapter/goDebug.ts
@@ -256,7 +256,6 @@
 	stackTraceDepth: number;
 
 	showGlobalVariables?: boolean;
-	currentFile: string;
 	packagePathToGoModPathMap: { [key: string]: string };
 }
 
@@ -282,7 +281,6 @@
 	stackTraceDepth: number;
 
 	showGlobalVariables?: boolean;
-	currentFile: string;
 }
 
 process.on('uncaughtException', (err: any) => {
@@ -427,46 +425,46 @@
 
 				if (!!launchArgs.noDebug) {
 					if (mode === 'debug') {
-						if (isProgramDirectory && launchArgs.currentFile) {
-							program = launchArgs.currentFile;
-							isProgramDirectory = false;
+						this.noDebug = true;
+						const runArgs = ['run'];
+						const runOptions: { [key: string]: any } = { env };
+						if (launchArgs.buildFlags) {
+							runArgs.push(launchArgs.buildFlags);
+						}
+						if (isProgramDirectory) {
+							runOptions.cwd = program;
+							runArgs.push('.');
+						} else {
+							runArgs.push(program);
+						}
+						if (launchArgs.args) {
+							runArgs.push(...launchArgs.args);
 						}
 
-						if (!isProgramDirectory) {
-							this.noDebug = true;
-							const runArgs = ['run'];
-							if (launchArgs.buildFlags) {
-								runArgs.push(launchArgs.buildFlags);
+						this.debugProcess = spawn(getBinPathWithPreferredGopath('go', []), runArgs, runOptions);
+						this.debugProcess.stderr.on('data', (chunk) => {
+							const str = chunk.toString();
+							if (this.onstderr) {
+								this.onstderr(str);
 							}
-							runArgs.push(program);
-							if (launchArgs.args) {
-								runArgs.push(...launchArgs.args);
+						});
+						this.debugProcess.stdout.on('data', (chunk) => {
+							const str = chunk.toString();
+							if (this.onstdout) {
+								this.onstdout(str);
 							}
-							this.debugProcess = spawn(getBinPathWithPreferredGopath('go', []), runArgs, { env });
-							this.debugProcess.stderr.on('data', (chunk) => {
-								const str = chunk.toString();
-								if (this.onstderr) {
-									this.onstderr(str);
-								}
-							});
-							this.debugProcess.stdout.on('data', (chunk) => {
-								const str = chunk.toString();
-								if (this.onstdout) {
-									this.onstdout(str);
-								}
-							});
-							this.debugProcess.on('close', (code) => {
-								logError('Process exiting with code: ' + code);
-								if (this.onclose) {
-									this.onclose(code);
-								}
-							});
-							this.debugProcess.on('error', (err) => {
-								reject(err);
-							});
-							resolve();
-							return;
-						}
+						});
+						this.debugProcess.on('close', (code) => {
+							logError('Process exiting with code: ' + code);
+							if (this.onclose) {
+								this.onclose(code);
+							}
+						});
+						this.debugProcess.on('error', (err) => {
+							reject(err);
+						});
+						resolve();
+						return;
 					}
 				}
 				this.noDebug = false;
diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts
index a9b50a5..e4cad2a 100644
--- a/src/goDebugConfiguration.ts
+++ b/src/goDebugConfiguration.ts
@@ -109,8 +109,6 @@
 			debugConfiguration['mode'] =

 				activeEditor && activeEditor.document.fileName.endsWith('_test.go') ? 'test' : 'debug';

 		}

-		debugConfiguration['currentFile'] =

-			activeEditor && activeEditor.document.languageId === 'go' && activeEditor.document.fileName;

 

 		const neverAgain = { title: `Don't Show Again` };

 		const ignoreWarningKey = 'ignoreDebugLaunchRemoteWarning';