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

Search for dlv in go.toolsGopath too #2108

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}
}