Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Search for dlv in go.toolsGopath too (#2108)
Browse files Browse the repository at this point in the history
* Search for dlv in go.toolsGopath too

Fixes #2099

* Fix review comments
  • Loading branch information
segevfiner authored and ramya-rao-a committed Nov 13, 2018
1 parent 03dc46a commit f460c6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
output?: string;
/** Delve LoadConfig parameters **/
dlvLoadConfig?: LoadConfig;
dlvToolPath: string;
/** Delve Version */
apiVersion: number;
}
Expand Down Expand Up @@ -356,11 +357,9 @@ class Delve {
return;
}

let dlv = getBinPathWithPreferredGopath('dlv', [resolveHomeDir(env['GOPATH']), process.env['GOPATH']]);

if (!existsSync(dlv)) {
verbose(`Couldn't find dlv at ${process.env['GOPATH']}${env['GOPATH'] ? ', ' + env['GOPATH'] : ''} or ${envPath}`);
return reject(`Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH".`);
if (!existsSync(launchArgs.dlvToolPath)) {
verbose(`Couldn't find dlv at the Go tools path, ${process.env['GOPATH']}${env['GOPATH'] ? ', ' + env['GOPATH'] : ''} or ${envPath}`);
return reject(`Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your Go tools path, "GOPATH/bin" or "PATH".`);
}

let currentGOWorkspace = getCurrentGoWorkspaceFromGOPATH(env['GOPATH'], dirname);
Expand Down Expand Up @@ -401,9 +400,9 @@ class Delve {
}

verbose(`Current working directory: ${dlvCwd}`);
verbose(`Running: ${dlv} ${dlvArgs.join(' ')}`);
verbose(`Running: ${launchArgs.dlvToolPath} ${dlvArgs.join(' ')}`);

this.debugProcess = spawn(dlv, dlvArgs, {
this.debugProcess = spawn(launchArgs.dlvToolPath, dlvArgs, {
cwd: dlvCwd,
env,
});
Expand Down
12 changes: 10 additions & 2 deletions src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

import vscode = require('vscode');
import { getCurrentGoPath, getToolsEnvVars, sendTelemetryEvent } from './util';
import path = require('path');
import { getCurrentGoPath, getToolsEnvVars, sendTelemetryEvent, getBinPath } from './util';
import { promptForMissingTool } from './goInstallTools';

export class GoDebugConfigurationProvider implements vscode.DebugConfigurationProvider {

Expand Down Expand Up @@ -78,11 +80,17 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig'];
}

debugConfiguration['dlvToolPath'] = getBinPath('dlv');
if (!path.isAbsolute(debugConfiguration['dlvToolPath'])) {
promptForMissingTool('dlv');
return;
}

if (debugConfiguration['mode'] === 'auto') {
debugConfiguration['mode'] = (activeEditor && activeEditor.document.fileName.endsWith('_test.go')) ? 'test' : 'debug';
}

return debugConfiguration;
}

}
}

0 comments on commit f460c6e

Please sign in to comment.